{"repo":"LiYanan2004/RichText","free":true,"listed":false,"github":"https://github.com/LiYanan2004/RichText","clone":"git clone https://github.com/LiYanan2004/RichText.git","description":"A supplementary TextView for SwiftUI that provides better text selection experience, as well as enabling native view embedding using declarative syntax","language":"Swift","stars":229,"topics":["swiftui","textview"],"license":"MIT","category":"mobile-apps","readme_excerpt":"RichText A supplementary TextView for SwiftUI that provides better text selection experience, as well as enabling native view embedding using declarative syntax. Requirements - Xcode 26.0+ - iOS 16.0+ - macOS 13.0+ Documentation You can view documentation on: - main @ Swift Package Index - main @ GitHub Pages Getting Started Add RichText as a dependency in your Swift Package Manager manifest. Include RichText in any targets that need it. Plain String & Attributed String TextView provides a result builder that accepts both plain string and AttributedString . Inline SwiftUI Views You can embed SwiftUI view along with other text as well, while preserving text selection capability. RichText will try to extract SwiftUI.Text content and convert it into AttributedString . If that fails, a plain string will be used instead. Other SwiftUI views are added as an individual text element , which means text selection will either include or exclude the entire view. Dynamic Views If the embedded view contains its own state, you will need to provide a unique view identifier using .id( :) to bind the view's identity, otherwise, its state will be reset whenever the textContent is recomputed. In the following example, the state of the globe icon will get reset when ContentView.body gets re-computed without explicit id specified. [!TIP] You may need to add .id( :) view modifier directly under embedded view. Currently, .id( :) inside View.Body is not recognizable. Troubleshooting SwiftUI Font is o","default_branch":null,"files":null,"tree":[],"storefront":"/r/LiYanan2004","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/LiYanan2004/RichText/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}