<!--
{
  "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/TextVariantPreference/sizeDependent",
  "metadataVersion" : "0.1.0",
  "role" : "Type Property",
  "symbol" : {
    "kind" : "Type Property",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI21TextVariantPreferencePA2A013SizeDependentcD0VRszrlE04sizeG0AEvpZ"
  },
  "title" : "sizeDependent"
}
-->

# sizeDependent

The size dependent preference allows the text to take the available space into
account when choosing the size variant to display.

```
static var sizeDependent: SizeDependentTextVariant { get }
```

## Discussion

When a [`Text`](/documentation/SwiftUI/Text) provides different size options for its content, the size
dependent preference chooses the largest option that fits into the available
space without truncating or clipping its content.

> Note: Only use this option where needed as it incurs a performance cost on
> every ``doc://com.apple.SwiftUI/documentation/SwiftUI/Text`` it is applied to, even if the concrete text initializer cannot
> provide multiple size variants and there is no visual impact.

## Difference to ViewThatFits

The [`sizeDependent`](/documentation/SwiftUI/TextVariantPreference/sizeDependent) text variant preference differs from [`ViewThatFits`](/documentation/SwiftUI/ViewThatFits) both
in usage and in behavior. [`ViewThatFits`](/documentation/SwiftUI/ViewThatFits) chooses the first child where the
**ideal** size fits the available space. For [`Text`](/documentation/SwiftUI/Text) this means that it will
only choose texts that can fit their contents into the available space **without
a line break**. With this text variant preference, on the other hand, the
largest variant is chosen that can fit the available space while respecting all
the regular layout rules, such as [`lineLimit`](/documentation/SwiftUI/EnvironmentValues/lineLimit).

To use [`ViewThatFits`](/documentation/SwiftUI/ViewThatFits), multiple different views have to be provided as the
different size options. With this text variant preference, a single [`Text`](/documentation/SwiftUI/Text)
provides the different size variants intrinsically. The way it generates these
size variants and how many size variants are available depends on the text
initializer used.

---

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)