dynamicTypeSize
Sets or constrains the Dynamic Type size within the view, overriding the value inherited from the system.
dynamicTypeSize(size)
Overload #1
| Parameter | Type |
|---|---|
size | DynamicTypeSizeValue |
Sets or constrains the Dynamic Type size within the view, overriding the value inherited from the system.
Four variants matching SwiftUI's dynamicTypeSize(_:):
dynamicTypeSize('large')— fixes the Dynamic Type size to a single valuedynamicTypeSize({ max: 'accessibility3' })— caps growth at a ceiling (...accessibility3)dynamicTypeSize({ min: 'large' })— sets a floor (large...)dynamicTypeSize({ min: 'large', max: 'accessibility3' })— clamps to a range (large...accessibility3)
min and max are independent: pass either or both. Set it on a <Host> to cascade the constraint to every descendant through the SwiftUI environment. Keep min at or below max, or the range traps natively, like SwiftUI. Per Apple's guidance, prefer capping at an accessibility size over disabling Dynamic Type entirely.
Returns: ModifierConfig
See: Official SwiftUI documentation.
Example
// Cap how large text in a tight layout can grow
<Host modifiers={[dynamicTypeSize({ max: 'accessibility3' })]}>...</Host>dynamicTypeSize(range)
Overload #2
| Parameter | Type |
|---|---|
range | { max: DynamicTypeSizeValue, min: DynamicTypeSizeValue } |
Sets or constrains the Dynamic Type size within the view, overriding the value inherited from the system.
Four variants matching SwiftUI's dynamicTypeSize(_:):
dynamicTypeSize('large')— fixes the Dynamic Type size to a single valuedynamicTypeSize({ max: 'accessibility3' })— caps growth at a ceiling (...accessibility3)dynamicTypeSize({ min: 'large' })— sets a floor (large...)dynamicTypeSize({ min: 'large', max: 'accessibility3' })— clamps to a range (large...accessibility3)
min and max are independent: pass either or both. Set it on a <Host> to cascade the constraint to every descendant through the SwiftUI environment. Keep min at or below max, or the range traps natively, like SwiftUI. Per Apple's guidance, prefer capping at an accessibility size over disabling Dynamic Type entirely.
Returns: ModifierConfig
See: Official SwiftUI documentation.
Example
// Cap how large text in a tight layout can grow
<Host modifiers={[dynamicTypeSize({ max: 'accessibility3' })]}>...</Host>Works with
This modifier works with any view. These components accept it:
- VStack
- HStack
- ZStack
- LazyVStack
- LazyHStack
- Group
- Spacer
- Divider
- Overlay
- ScrollView
- Button
- Toggle
- Checkbox
- Slider
- Picker
- DatePicker
- ColorPicker
- Link
- ControlGroup
- Menu
- ContextMenu
- TextField
- SecureField
- Text
- Label
- Image
- List
- Form
- Section
- DisclosureGroup
- SwipeActions
- BottomSheet
- Alert
- ConfirmationDialog
- Popover
- ProgressView
- Gauge
- TabView
- AccessoryWidgetBackground
Sources
The original Expo docs for this page:
- dynamicTypeSize (Modifiers) (
source-of-truth/versions/v57.0.0/sdk/ui/swift-ui/modifiers.md)