Modifiers
contentTransition
Sets the content transition type for a view.
contentTransition(transitionType, params)
iOS 16+
| Parameter | Type | Description |
|---|---|---|
transitionType | 'opacity' | 'identity' | 'numericText' | 'interpolate' | The type of content transition. |
params(optional) | { countsDown: boolean } | Optional parameters. |
Sets the content transition type for a view.
- Useful for animating changes in text content, especially numeric text.
- Use with the 0 modifier to animate the transition when the content changes.
Returns: ModifierConfig
See: Official SwiftUI documentation.
Example
<Text modifiers={[contentTransition('numericText'), animation(Animation.default, count)]}>
{count.toString()}
</Text>Works with
You can add contentTransition 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 how text and SF Symbols animate when their content changes, and Spacer shows neither. |
| Divider | It changes how text and SF Symbols animate when their content changes, and Divider shows neither. |
| Slider | It changes how text and SF Symbols animate when their content changes, and Slider shows neither. |
| AccessoryWidgetBackground | It changes how text and SF Symbols animate when their content changes, and AccessoryWidgetBackground shows neither. |
Sources
The original Expo docs for this page:
- contentTransition (Modifiers) (
source-of-truth/versions/v57.0.0/sdk/ui/swift-ui/modifiers.md)