Modifiers
lineLimit
Sets the line limit for text in the view.
lineLimit()
Overload #1
Sets the line limit for text in the view.
Four variants matching SwiftUI:
lineLimit()— no line limit (unlimited lines)lineLimit(5)— max 5 lineslineLimit(5, { reservesSpace: true })— max 5 lines, reserves height even when empty (iOS 16+, tvOS 16+)lineLimit({ min: 3, max: 8 })— range of 3 to 8 lines (iOS 16+, tvOS 16+)
Returns: ModifierConfig
See: Official SwiftUI documentation.
lineLimit(limit, options)
Overload #2
| Parameter | Type |
|---|---|
limit | number |
options(optional) | { reservesSpace: boolean } |
Sets the line limit for text in the view.
Four variants matching SwiftUI:
lineLimit()— no line limit (unlimited lines)lineLimit(5)— max 5 lineslineLimit(5, { reservesSpace: true })— max 5 lines, reserves height even when empty (iOS 16+, tvOS 16+)lineLimit({ min: 3, max: 8 })— range of 3 to 8 lines (iOS 16+, tvOS 16+)
Returns: ModifierConfig
See: Official SwiftUI documentation.
lineLimit(range)
Overload #3
| Parameter | Type |
|---|---|
range | { max: number, min: number } |
Sets the line limit for text in the view.
Four variants matching SwiftUI:
lineLimit()— no line limit (unlimited lines)lineLimit(5)— max 5 lineslineLimit(5, { reservesSpace: true })— max 5 lines, reserves height even when empty (iOS 16+, tvOS 16+)lineLimit({ min: 3, max: 8 })— range of 3 to 8 lines (iOS 16+, tvOS 16+)
Returns: ModifierConfig
See: Official SwiftUI documentation.
Works with
You can add lineLimit to any view. It changes what you see on 34 of the 39 components.
- VStack
- HStack
- ZStack
- LazyVStack
- LazyHStack
- Group
- Overlay
- ScrollView
- Button
- Toggle
- Checkbox
- Picker
- DatePicker
- ColorPicker
- Link
- ControlGroup
- Menu
- ContextMenu
- TextField
- SecureField
- Text
- Label
- List
- Form
- Section
- DisclosureGroup
- SwipeActions
- BottomSheet
- Alert
- ConfirmationDialog
- Popover
- ProgressView
- Gauge
- TabView
No visible effect
These components accept it, but you see no change.
| Component | Why nothing happens |
|---|---|
| Spacer | It changes only text, and Spacer shows no text. |
| Divider | It changes only text, and Divider shows no text. |
| Slider | It changes only text, and Slider shows no text. |
| Image | It changes only text, and Image shows no text. |
| AccessoryWidgetBackground | It changes only text, and AccessoryWidgetBackground shows no text. |
Sources
The original Expo docs for this page:
- lineLimit (Modifiers) (
source-of-truth/versions/v57.0.0/sdk/ui/swift-ui/modifiers.md)