Modifiers
Modifiers
All the SwiftUI modifiers, and the components that accept each one.
Usage
Modifiers are applied to components using the modifiers prop with an array syntax. You can combine multiple modifiers to create complex styling and behavior.
import { Text, Host, VStack } from '@expo/ui/swift-ui';
import {
background,
cornerRadius,
padding,
shadow,
foregroundColor,
onTapGesture,
} from '@expo/ui/swift-ui/modifiers';
function ModifiersExample() {
const [isEnabled, setIsEnabled] = useState(false);
return (
<Host style={{ flex: 1 }}>
<VStack spacing={20}>
{/* Basic styling modifiers */}
<Text
modifiers={[
background('#FF6B6B'),
cornerRadius(12),
padding({ all: 16 }),
foregroundColor('#FFFFFF'),
]}>
Basic styled text
</Text>
{/* Complex combination with shadow and interaction */}
<Text
modifiers={[
background('#4ECDC4'),
cornerRadius(16),
padding({ horizontal: 20, vertical: 12 }),
shadow({ radius: 4, x: 0, y: 2, color: '#4ECDC440' }),
onTapGesture(() => console.log('Tapped!')),
]}>
Styled with shadow and tap gesture
</Text>
{/* Conditional modifiers using spread operator */}
<Text
modifiers={[
background('#9B59B6'),
cornerRadius(8),
padding({ all: 14 }),
...(isEnabled
? [shadow({ radius: 6, y: 3 }), scaleEffect(1.02)]
: [grayscale(0.5), opacity(0.7)]),
]}>
Conditional styling
</Text>
</VStack>
</Host>
);
}You can also create custom modifiers that work with any Expo UI component. See the Extending with SwiftUI guide for details.
API
import { background, cornerRadius, padding, shadow, foregroundColor, onTapGesture } from '@expo/ui/swift-ui/modifiers';All modifiers
| Modifier | Minimum iOS | Works with |
|---|---|---|
accessibilityAddTraits | Any view | |
accessibilityElement | Any view, but no effect on 19 of 39 components | |
accessibilityHidden | Any view | |
accessibilityHint | Any view | |
accessibilityIdentifier | Any view | |
accessibilityInputLabels | Any view | |
accessibilityLabel | Any view | |
accessibilityRemoveTraits | Any view | |
accessibilityValue | Any view | |
activityBackgroundTint | Any view. Works only in a Live Activity. It has no effect in the app. | |
alignmentGuide | Any view. Has an effect only when the parent, such as a VStack or ZStack, aligns its children by the same guide. | |
allowsTightening | Any view, but no effect on 5 of 39 components | |
animation | Any view | |
aspectRatio | Any view | |
autocorrectionDisabled | TextField, SecureField | |
background | Any view, but no effect on 1 of 39 components | |
backgroundOverlay | Any view, but no effect on 1 of 39 components | |
badge | List, TabView | |
badgeProminence | List | |
blur | Any view, but no effect on 1 of 39 components | |
bold | Any view, but no effect on 4 of 39 components | |
border | Any view, but no effect on 1 of 39 components | |
brightness | Any view, but no effect on 1 of 39 components | |
buttonBorderShape | Button | |
buttonStyle | Button, Link | |
clipped | Any view, but no effect on 1 of 39 components | |
clipShape | Any view, but no effect on 1 of 39 components | |
colorInvert | Any view, but no effect on 1 of 39 components | |
containerBackground | Any view. Works only in a widget, or in a navigation container when you use a navigation placement. | |
containerRelativeFrame | 17+ | Any view |
containerShape | Any view, but no effect on 19 of 39 components | |
contentShape | Any view, but no effect on 5 of 39 components | |
contentTransition | 16+ | Any view, but no effect on 4 of 39 components |
contrast | Any view, but no effect on 1 of 39 components | |
controlSize | Button, Toggle, Checkbox, Slider, Picker, DatePicker, ColorPicker, Link, ControlGroup, Menu, TextField, SecureField, ProgressView, Gauge | |
cornerRadius | Any view, but no effect on 1 of 39 components | |
createModifier | This is not a modifier. It is a function that makes the config for a custom native modifier. | |
datePickerStyle | DatePicker | |
defaultScrollAnchor | 17+ | ScrollView, List, Form |
defaultScrollAnchorForRole | 18+ | ScrollView, List, Form |
deleteDisabled | List | |
disabled | Any view, but no effect on 6 of 39 components | |
dynamicTypeSize | Any view, but no effect on 4 of 39 components | |
environment | Any view | |
fixedSize | Any view | |
font | Any view, but no effect on 4 of 39 components | |
foregroundColor | Any view, but no effect on 2 of 39 components | |
foregroundStyle | Any view, but no effect on 2 of 39 components | |
frame | Any view | |
gaugeStyle | Gauge | |
geometryGroup | 17+ | Any view, but no effect on 19 of 39 components |
glassEffect | Any view, but no effect on 1 of 39 components | |
glassEffectId | Any view. Works only on a view that also has glassEffect, in a GlassEffectContainer and a Namespace. | |
grayscale | Any view, but no effect on 1 of 39 components | |
gridCellAnchor | 16+ | Any view. Works only on a cell of a Grid. Grid is in @expo/ui/swift-ui, but it has no Expo docs page. |
gridCellColumns | Any view. Works only on a view in a Grid.Row. Grid is in @expo/ui/swift-ui, but it has no Expo docs page. | |
gridCellUnsizedAxes | Any view. Works only on a view in a Grid. Grid is in @expo/ui/swift-ui, but it has no Expo docs page. | |
gridColumnAlignment | 16+ | Any view. Works only on a view in a Grid.Row. Grid is in @expo/ui/swift-ui, but it has no Expo docs page. |
headerProminence | Section | |
hidden | Any view, but no effect on 1 of 39 components | |
hueRotation | Any view, but no effect on 1 of 39 components | |
id | Any view | |
ignoreSafeArea | Any view | |
imageScale | Any view, but no effect on 14 of 39 components | |
indexViewStyle | TabView | |
interactiveDismissDisabled | BottomSheet | |
invalidatableContent | 17+ | Any view. Has an effect only when a parent view uses redacted with the invalidated reason. |
italic | Any view, but no effect on 5 of 39 components | |
kerning | Any view, but no effect on 5 of 39 components | |
keyboardType | TextField, SecureField | |
labelsHidden | Toggle, Checkbox, Slider, Picker, DatePicker, ColorPicker, ProgressView, Gauge | |
labelStyle | Button, Menu, Label | |
layoutPriority | Any view, but no effect on 33 of 39 components | |
lineHeight | 26+ | Any view, but no effect on 5 of 39 components |
lineLimit | Any view, but no effect on 5 of 39 components | |
lineSpacing | Any view, but no effect on 5 of 39 components | |
listRowBackground | List, Form, Section | |
listRowInsets | List, Form, Section | |
listRowSeparator | List, Form, Section | |
listRowSeparatorTint | List, Form, Section | |
listRowSpacing | 15+ | List, Form |
listSectionMargins | 26+ | List, Form |
listSectionSpacing | 17+ | List, Form |
listStyle | List | |
luminanceToAlpha | Any view, but no effect on 1 of 39 components | |
mask | Any view, but no effect on 1 of 39 components | |
matchedGeometryEffect | Any view. Works only in a Namespace. Give two views the same id and change between them with an animation. | |
menuActionDismissBehavior | 16.4+ | Menu, ContextMenu |
menuOrder | Menu, ContextMenu | |
minimumScaleFactor | Any view, but no effect on 5 of 39 components | |
monospacedDigit | Any view, but no effect on 5 of 39 components | |
moveDisabled | List | |
multilineTextAlignment | Any view, but no effect on 5 of 39 components | |
offset | Any view, but no effect on 1 of 39 components | |
onAppear | Any view, but no effect on 6 of 39 components | |
onDisappear | Any view, but no effect on 6 of 39 components | |
onGeometryChange | Any view, but no effect on 6 of 39 components | |
onLongPressGesture | Any view, but no effect on 8 of 39 components | |
onScrollPhaseChange | 18+ | ScrollView, List, Form |
onSubmit | TextField, SecureField | |
onTapGesture | Any view, but no effect on 12 of 39 components | |
opacity | Any view, but no effect on 1 of 39 components | |
overlay | Any view, but no effect on 1 of 39 components | |
padding | Any view | |
pickerStyle | Picker | |
presentationBackground | 16.4+ | BottomSheet, Popover |
presentationBackgroundInteraction | 16.4+ | BottomSheet |
presentationDetents | 16+ | BottomSheet, Popover |
presentationDragIndicator | 16+ | BottomSheet, Popover |
presentationSizing | 18+ | BottomSheet |
privacySensitive | Any view. Has an effect only when a parent view uses redacted with the privacy reason. | |
progressViewStyle | ProgressView | |
redacted | Any view, but no effect on 1 of 39 components | |
refreshable | ScrollView, List, Form | |
resizable | Image | |
rotation3DEffect | Any view, but no effect on 1 of 39 components | |
rotationEffect | Any view, but no effect on 1 of 39 components | |
saturation | Any view, but no effect on 1 of 39 components | |
scaleEffect | Any view, but no effect on 1 of 39 components | |
scrollContentBackground | List, Form | |
scrollDisabled | 16+ | ScrollView, List, Form |
scrollDismissesKeyboard | 16+ | ScrollView, List, Form |
scrollIndicators | 16+ | ScrollView, List, Form |
scrollPosition | 17+ | ScrollView, List, Form |
scrollTargetBehavior | 17+ | ScrollView, List, Form |
scrollTargetLayout | 17+ | VStack, HStack, LazyVStack, LazyHStack |
shadow | Any view, but no effect on 1 of 39 components | |
strikethrough | Any view, but no effect on 5 of 39 components | |
strokeBorder | Any view, but no effect on 1 of 39 components | |
submitLabel | 15+ | TextField, SecureField |
symbolEffect | 17+ | Label, Image |
tabViewStyle | TabView | |
tag | Picker | |
textCase | Any view, but no effect on 5 of 39 components | |
textContentType | 13+ | TextField, SecureField |
textFieldStyle | TextField, SecureField | |
textInputAutocapitalization | 15+ | TextField, SecureField |
textSelection | Text | |
tint | Any view, but no effect on 4 of 39 components | |
toggleStyle | Toggle, Checkbox | |
truncationMode | Any view, but no effect on 5 of 39 components | |
underline | Any view, but no effect on 5 of 39 components | |
unredacted | Any view. Has an effect only in a parent view that uses redacted. | |
widgetAccentedRenderingMode | Image | |
widgetURL | Any view. Works only in a widget. It has no effect in the app. | |
zIndex | Any view, but no effect on 37 of 39 components |
Sources
The original Expo docs for this page:
- Modifiers (
source-of-truth/versions/v57.0.0/sdk/ui/swift-ui/modifiers.md)