Instance Method


Sets the maximum number of lines that text can occupy in the view.


func lineLimit(_ number: Int?) -> some View



The line limit. If nil, no line limit applies.

Return Value

A view that limits the number of lines that Text instances display.


The line limit applies to all Text instances within this view. For example, an HStack with multiple pieces of text longer than three lines caps each piece of text to three lines rather than capping the total number of lines across the HStack.

See Also

Adjusting Text in a View

func font(Font?) -> View

Sets the default font for text in the view.

func lineSpacing(CGFloat) -> View

Sets the amount of space between lines of text in the view.

func minimumScaleFactor(CGFloat) -> View

Sets the minimum amount that text scales down to fit the available space.

func truncationMode(Text.TruncationMode) -> View

Sets the truncation mode for lines of text that are too long to fit in the available space.

func allowsTightening(Bool) -> View

Sets whether text can compress the space between characters when necessary to fit text in a line.

func flipsForRightToLeftLayoutDirection(Bool) -> View

Sets whether the view flips its contents horizontally when the layout direction is right-to-left.

func disableAutocorrection(Bool?) -> View

Sets whether to disable autocorrection for this view.