<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/Text/textVariant(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4TextV11textVariantyQrxAA0cE10PreferenceRzlF"
  },
  "title" : "textVariant(_:)"
}
-->

# textVariant(_:)

Controls the way text size variants are chosen.

```
func textVariant<V>(_ preference: V) -> some View where V : TextVariantPreference
```

## Discussion

Certain types of text, such as `Text(_:format:)`, can generate strings of
different size to better fit the available space. By default, all text uses the
widest available variant. Setting the variant to be
[`sizeDependent`](/documentation/SwiftUI/TextVariantPreference/sizeDependent) allows the text to take the available
space into account when choosing what content to display.

---

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)