A beautifully crafted SwiftUI package that enables smooth, animated text expansion with native-feeling truncation and blur transitions --- powered by modern iOS text rendering APIs.
Built for developers who want pixel-perfect control over text behavior without compromising performance or API simplicity.
ExpandableText is not just a "Read More" solution --- it's a custom rendering system for text expansion.
- ⚡ Zero boilerplate integration
- 🎯 Precise line-based truncation
- 🎬 Smooth animated expansion
- 🌫 Native blur-based reveal effect
- 🧠 Built using
TextRenderer(iOS 18+) - 🧩 Clean modifier-based API
- 🎨 Fully customizable trailing text ("...More")
To integrate ExpandableText using Swift Package Manager, add the following dependency to your Package.swift:
dependencies: [
.package(url: "https://github.com/thakur-vijay/ExpandableText.git", from: "1.0.0")
]Then add the package to your target:
.target(
name: "YourTarget",
dependencies: ["ExpandableText"]
)Or add it directly in Xcode:
File → Add Package Dependencies…
Enter the repository URL:
https://github.com/thakur-vijay/ExpandableText.git
import ExpandableText- iOS 18.0+
- SwiftUI
import SwiftUI
import ExpandableText
struct ContentView: View {
@State private var isCollapsed = true
var body: some View {
Text("Long text goes here...")
.expandable(
length: 3,
isEnabled: isCollapsed,
moreText: "...More",
blurRadius: 2,
animation: .easeInOut
)
.onTapGesture {
isCollapsed.toggle()
}
}
}| Parameter | Description |
|---|---|
length |
Number of visible lines |
isEnabled |
Controls collapse state |
moreText |
Trailing text |
blurRadius |
Blur intensity |
animation |
Transition animation |
- Custom
TextRenderer - Line-by-line drawing
- Blur + opacity animation
- Injected trailing text
- Use 2--4 lines
- Keep text short
- Use subtle animations
MIT License
If you find this project useful:
- ⭐ Star the repository
- 🧃 Or… let users tip you through it 😄