DynamicTypeSize
A Dynamic Type size, which specifies how large scalable content should be.
Declaration
type DynamicTypeSize =
| 'accessibility1'
| 'accessibility2'
| 'accessibility3'
| 'accessibility4'
| 'accessibility5'
| 'large'
| 'medium'
| 'small'
| 'xLarge'
| 'xSmall'
| 'xxLarge'
| 'xxxLarge';enum DynamicTypeSizePass a literal, or build one with SwiftUI.DynamicTypeSize from import { SwiftUI } from 'swiftui-react-native'.
Type properties
'accessibility1'SwiftUI.DynamicTypeSize.accessibility1The first accessibility size.
'accessibility2'SwiftUI.DynamicTypeSize.accessibility2The second accessibility size.
'accessibility3'SwiftUI.DynamicTypeSize.accessibility3The third accessibility size.
'accessibility4'SwiftUI.DynamicTypeSize.accessibility4The fourth accessibility size.
'accessibility5'SwiftUI.DynamicTypeSize.accessibility5The fifth accessibility size.
'large'SwiftUI.DynamicTypeSize.largeA large size.
'medium'SwiftUI.DynamicTypeSize.mediumA medium size.
'small'SwiftUI.DynamicTypeSize.smallA small size.
'xLarge'SwiftUI.DynamicTypeSize.xLargeAn extra large size.
'xSmall'SwiftUI.DynamicTypeSize.xSmallAn extra small size.
'xxLarge'SwiftUI.DynamicTypeSize.xxLargeAn extra extra large size.
'xxxLarge'SwiftUI.DynamicTypeSize.xxxLargeAn extra extra extra large size.
Overview
Read this value from the environment to adapt a layout to the text size someone chooses in system settings. The sizes are ordered, so you can compare them to find out how much room the text needs.
struct BatteryLabel: View {
@Environment(\.dynamicTypeSize) private var dynamicTypeSize
var body: some View {
if dynamicTypeSize >= .accessibility1 {
VStack {
BatteryIcon()
Text("Charging")
}
} else {
HStack {
BatteryIcon()
Text("Charging")
}
}
}
}The five sizes whose names begin with accessibility are much larger than
the rest. Check DynamicTypeSize.isAccessibilitySize when you want to
change a layout for those sizes without comparing sizes yourself.
For more information, see doc://com.apple.documentation/design/human-interface-guidelines/typography in the Human Interface Guidelines.
From Apple’s SwiftUI documentation. Code samples there are Swift.
Used by
See also
More in Layout.
- AlignmentAn alignment in both axes.
- ContainerBackgroundPlacementThe placement of a container background.
- ContainerValuesReadableKeys of SwiftUI ContainerValues JavaScript can read.
- ContainerValuesWritableKeys of SwiftUI ContainerValues JavaScript can write.
- ControlSizeThe size classes, like regular or small, that you can apply to controls within a view.
- DocumentLaunchGeometryProxyA proxy for access to the frame of the scene and its title view.
- EdgeAn enumeration to indicate one edge of a rectangle.
- EdgeInsetsThe inset distances for the sides of a rectangle.
- EdgeInsetsChainEdgeInsets with chained calls: SwiftUI.EdgeInsets.inset(...).
- EdgeSetAn efficient set of edges.
- GeometryProxyA proxy for access to the size and coordinate space (for anchor resolution) of the container view.
- GridItemA description of a row or a column in a lazy grid.