lineLimit

Sets to a partial range the number of lines that text can occupy in this view.

View ModifieriOS 16.0+macOS 13.0+tvOS 16.0+watchOS 9.0+

Overloads

5 ways to call compose().lineLimit(). Each is one SwiftUI overload, picked by the arguments you pass.

React
compose().lineLimit({
  from: number,
})
Swift
nonisolated func lineLimit(_ limit: PartialRangeFrom<Int>) -> some View

Parameters

  • limit.from*number

Discussion

Use this modifier to specify a partial range of lines that a Text view or a vertical TextField can occupy. When the text of such views occupies less space than the provided limit, that view expands to occupy the minimum number of lines.

Form {
    TextField("Title", text: $model.title)
    TextField("Notes", text: $model.notes, axis: .vertical)
        .lineLimit(3...)
}

See also

More in Text and symbols.