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
minat or belowmax, 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
minat or belowmax, 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
You can add dynamicTypeSize to any view. It changes what you see on 35 of the 39 components.
- VStack
- HStack
- ZStack
- LazyVStack
- LazyHStack
- Group
- Overlay
- ScrollView
- Button
- Toggle
- Checkbox
- Picker
- DatePicker
- ColorPicker
- Link
- ControlGroup
- Menu
- ContextMenu
- TextField
- SecureField
- Text
- Label
- Image
- List
- Form
- Section
- DisclosureGroup
- SwipeActions
- BottomSheet
- Alert
- ConfirmationDialog
- Popover
- ProgressView
- Gauge
- TabView
No visible effect
These components accept it, but you see no change.
| Component | Why nothing happens |
|---|---|
| Spacer | It changes only text and SF Symbols, and Spacer shows neither. |
| Divider | It changes only text and SF Symbols, and Divider shows neither. |
| Slider | It changes only text and SF Symbols, and Slider shows neither. |
| AccessoryWidgetBackground | It changes only text and SF Symbols, and AccessoryWidgetBackground shows neither. |
Sources
The original Expo docs for this page:
- dynamicTypeSize (Modifiers) (
source-of-truth/versions/v57.0.0/sdk/ui/swift-ui/modifiers.md)