<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/lineLimit(_:)-513mb",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE9lineLimityQrSiSgF"
  },
  "title" : "lineLimit(_:)"
}
-->

# lineLimit(_:)

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

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

## Parameters

`number`

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

## Return Value

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

## Discussion

Use this modifier to cap the number of lines that an individual text
element can display.

The line limit applies to all `Text` instances within a hierarchy. 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`.

In the example below, the modifier limits the very long
line in the `Text` element to the 2 lines that fit within the view’s
bounds:

```
Text("This is a long string that demonstrates the effect of SwiftUI's lineLimit(:_) operator.")
    .frame(width: 200, height: 200, alignment: .leading)
    .lineLimit(2)
```

![A screenshot showing showing the effect of the line limit operator on](images/com.apple.SwiftUI/SwiftUI-view-lineLimit@2x.png)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)