This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
Modifiers
SwiftUI view modifiers for customizing component appearance and behavior.
SwiftUI view modifiers that allow you to customize the appearance and behavior of UI components.
Installation
If you are installing this in an existing React Native app, make sure to install expo in your project.
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';
Constants
Built-in animation presets for the animation modifier.
Presets:
- Timing presets (
easeInOut,easeIn,easeOut,linear) acceptTimingAnimationParams. springacceptsSpringAnimationParams.interpolatingSpringacceptsInterpolatingSpringAnimationParams.- Chaining returns
ChainableAnimationType.
Example
import { Host, VStack } from '@expo/ui/swift-ui'; import { animation, Animation } from '@expo/ui/swift-ui/modifiers'; function Example() { const [isExpanded, setIsExpanded] = useState(false); return ( <Host style={{ flex: 1 }}> <VStack modifiers={[animation(Animation.spring({ duration: 0.8 }), isExpanded)]}> //... </VStack> </Host> ); }
Shape builders for modifiers that accept shapes, such as background and containerShape.
Shapes: roundedRectangle, capsule, rectangle, ellipse, circle.
Example
import { background, shapes } from '@expo/ui/swift-ui/modifiers'; import { Text, Host } from '@expo/ui/swift-ui'; function Example() { return ( <Host> <Text modifiers={[ background('#000', shapes.roundedRectangle({ cornerRadius: 12 })), ]} > Hello, world! </Text> </Host> ); }
Methods
Sets whether text in this view can compress the space between characters when necessary to fit text in a line
ModifierConfigSee: Official SwiftUI documentation.
Disables autocorrection for text input views.
ModifierConfigSee: Official SwiftUI documentation.
Generates a badge for the view from a localized string key.
ModifierConfigSee: Official SwiftUI documentation.
The prominence to apply to badges associated with this environment.
ModifierConfigSee: Official SwiftUI documentation.
Makes text bold.
When applied to Text, it works on all iOS/tvOS versions. When used on regular views, it requires iOS 16.0+/tvOS 16.0+.
ModifierConfigSee: Official SwiftUI documentation.
Positions this view within an invisible frame with a size relative to the nearest container.
ModifierConfigSee: Official SwiftUI documentation.
Defines the content shape for hit-testing purposes.
This modifier is essential for making entire view areas (including Spacer or empty space)
interactive. Without it, only visible elements like Text or Image respond to tap gestures.
ModifierConfigSee: Official SwiftUI documentation.
Example
import { HStack, List, Section, Spacer, Text } from "@expo/ui/swift-ui"; import { contentShape, onTapGesture } from "@expo/ui/swift-ui/modifiers"; import { shapes } from "@expo/ui/swift-ui/modifiers"; function InteractiveRow() { return ( <List> <Section title="Settings"> <HStack modifiers={[ contentShape(shapes.rectangle()), onTapGesture(() => console.log("Row tapped!")) ]} > <Text>Label</Text> <Spacer /> <Text>Value</Text> </HStack> </Section> </List> ); }
Sets the content transition type for a view.
Useful for animating changes in text content, especially numeric text.
Use with the animation modifier to animate the transition when the content changes.
ModifierConfigSee: Official SwiftUI documentation.
Example
<Text modifiers={[contentTransition('numericText'), animation(Animation.default, count)]}> {count.toString()} </Text>
Sets the size of controls within this view.
ModifierConfigSee: Official SwiftUI documentation.
Factory function to create modifier configuration objects. This is used by all built-in modifier functions and can be used by 3rd party libraries to create custom modifiers.
ModifierConfigA ModifierConfig object that can be passed in the modifiers prop array.
Example
// In a 3rd party package import { createModifier } from '@expo/ui/swift-ui/modifiers'; export const blurEffect = (params: { radius: number; style?: string }) => createModifier('blurEffect', params);
Sets the default anchor point for a scroll view's content.
ModifierConfigSee: Official SwiftUI documentation.
Sets the default anchor point for a scroll view for a specific role.
Pass null to opt out of a specific role while keeping anchors for other roles.
ModifierConfigSee: Official SwiftUI documentation.
Disables the delete action for a view in a list.
Apply to items within a ForEach to prevent them from being deleted.
ModifierConfigSee: Official SwiftUI documentation.
Sets the font properties of a view. Supports both custom font families and system fonts with weight and design options.
ModifierConfigSee: Official SwiftUI documentation for
custom(_:size:)and Official SwiftUI documentation forsystem(size:weight:design:).
Example
// Custom font family <Text modifiers={[font({ family: 'Helvetica', size: 18 })]}>Custom Font Text</Text> // System font with weight and design <Text modifiers={[font({ weight: 'bold', design: 'rounded', size: 16 })]}>System Font Text</Text>
Deprecated: Use
foregroundStyleinstead.
Sets the foreground style of a view with comprehensive styling options.
Replaces the deprecated foregroundColor modifier with enhanced capabilities including
colors, gradients, and semantic hierarchical styles that adapt to system appearance.
ModifierConfigA view modifier that applies the specified foreground style
See: Official SwiftUI documentation.
Example
// Simple usage <Text modifiers={[foregroundStyle('#FF0000')]}>Red Text</Text> // Adaptive hierarchical styling <Text modifiers={[foregroundStyle({ type: 'hierarchical', style: 'secondary' })]}> Supporting Text </Text> // Linear gradient <Text modifiers={[foregroundStyle({ type: 'linearGradient', colors: ['#FF6B35', '#F7931E', '#FFD23F'], startPoint: { x: 0, y: 0 }, endPoint: { x: 1, y: 0 } })]}> Gradient Text </Text>
Associates an identity value to Liquid Glass effects defined within a GlassEffectContainer.
ModifierConfigSee: Official SwiftUI documentation.
Specifies a custom alignment anchor for a view that acts as a grid cell.
ModifierConfigA view that uses the specified anchor point to align its content.
Example
// Using a preset anchor <Rectangle modifiers={[ gridCellAnchor({ type: 'preset', anchor: 'center' }), ]} /> // Using a custom anchor point <Rectangle modifiers={[ gridCellAnchor({ type: 'custom', points: { x: 0.3, y: 0.8 } }), ]} />
Tells a view that acts as a cell in a grid to span the specified number of columns.
ModifierConfigA view that occupies the specified number of columns in a grid row.
Asks grid layouts not to offer the view extra size in the specified axes.
ModifierConfigA view that doesn’t ask an enclosing grid for extra size in one or more axes.
Overrides the default horizontal alignment of the grid column that the view appears in.
ModifierConfigA view that uses the specified horizontal alignment, and that causes all cells in the same column of a grid to use the same alignment.
Allows a view to ignore safe area constraints.
ModifierConfigSee: Official SwiftUI documentation.
Disables interactive dismissal of a sheet.
ModifierConfigSee: Official SwiftUI documentation.
Makes text italic.
When applied to Text, it works on all iOS/tvOS versions. When used on regular views, it requires iOS 16.0+/tvOS 16.0+.
ModifierConfigSee: Official SwiftUI documentation.
Sets the spacing, or kerning, between characters for the text in this view.
ModifierConfigSee: Official SwiftUI documentation.
Sets the keyboard type for text input views.
ModifierConfigSee: Official SwiftUI documentation.
Hides the labels of any controls contained within this view.
ModifierConfigSee: Official SwiftUI documentation.
Sets the style for labels within this view.
ModifierConfigSee: Official SwiftUI documentation.
Sets the line limit for text in the view.
Four variants matching SwiftUI:
lineLimit()— no line limit (unlimited lines)lineLimit(5)— max 5 lineslineLimit(5, { reservesSpace: true })— max 5 lines, reserves height even when empty (iOS 16+, tvOS 16+)lineLimit({ min: 3, max: 8 })— range of 3 to 8 lines (iOS 16+, tvOS 16+)
ModifierConfigSee: Official SwiftUI documentation.
Sets the line limit for text in the view.
Four variants matching SwiftUI:
lineLimit()— no line limit (unlimited lines)lineLimit(5)— max 5 lineslineLimit(5, { reservesSpace: true })— max 5 lines, reserves height even when empty (iOS 16+, tvOS 16+)lineLimit({ min: 3, max: 8 })— range of 3 to 8 lines (iOS 16+, tvOS 16+)
ModifierConfigSee: Official SwiftUI documentation.
Sets the line limit for text in the view.
Four variants matching SwiftUI:
lineLimit()— no line limit (unlimited lines)lineLimit(5)— max 5 lineslineLimit(5, { reservesSpace: true })— max 5 lines, reserves height even when empty (iOS 16+, tvOS 16+)lineLimit({ min: 3, max: 8 })— range of 3 to 8 lines (iOS 16+, tvOS 16+)
ModifierConfigSee: Official SwiftUI documentation.
The distance in points between the bottom of one line fragment and the top of the next.
ModifierConfigSee: Official SwiftUI documentation.
Controls the visibility of the separator for a list row.
ModifierConfigSee: Official SwiftUI documentation.
Allows a view to ignore safe area constraints.
ModifierConfigSee: Official SwiftUI documentation.
Sets the spacing between adjacent sections.
ModifierConfigAdds a luminance to alpha effect to this view.
ModifierConfigSee: Official SwiftUI documentation.
Controls the dismissal behavior of menu actions.
ModifierConfigSee: Official SwiftUI documentation.
Modifies the fonts of all child views to use fixed-width digits, if possible, while leaving other characters proportionally spaced.
When applied to Text, modifies the text view's font to use fixed-width digits, while leaving other characters proportionally spaced.
ModifierConfigSee: Official SwiftUI documentation.
Disables the move action for a view in a list.
Apply to items within a ForEach to prevent them from being moved.
ModifierConfigSee: Official SwiftUI documentation.
An alignment position for text along the horizontal axis.
ModifierConfigSee: Official SwiftUI documentation.
Applies an offset (translation) to a view.
ModifierConfigSee: Official SwiftUI documentation.
Adds an onAppear modifier that calls a function when the view appears.
ModifierConfigSee: Official SwiftUI documentation.
Adds an onDisappear modifier that calls a function when the view disappears.
ModifierConfigSee: Official SwiftUI documentation.
Adds a long press gesture recognizer.
ModifierConfigAdds an action to perform when the user submits a value to this view (e.g. pressing return in a text field).
ModifierConfigSee: Official SwiftUI documentation.
Sets padding on a view. Supports individual edges or shorthand properties.
ModifierConfigSee: Official SwiftUI documentation.
Controls interaction with the content behind a sheet.
ModifierConfigSee: Official SwiftUI documentation.
Sets the available heights for a sheet presentation.
ModifierConfigSee: Official SwiftUI documentation.
Controls the visibility of the drag indicator on a sheet.
ModifierConfigSee: Official SwiftUI documentation.
Marks a view as refreshable. Adds pull-to-refresh functionality.
ModifierConfigSee: Official SwiftUI documentation.
Sets the mode by which SwiftUI resizes an image to fit its space.
ModifierConfigSee: Official SwiftUI documentation.
Specifies the visibility of the background for scrollable views within this view.
ModifierConfigSee: Official SwiftUI documentation.
Disables or enables scrolling in scrollable views.
ModifierConfigSee: Official SwiftUI documentation.
Controls how the keyboard is dismissed when scrolling.
ModifierConfigSee: Official SwiftUI documentation.
Sets the scroll snapping behavior for scrollable views.
Use with scrollTargetLayout on the content container.
ModifierConfigSee: Official SwiftUI documentation.
Configures a layout container as a scroll target layout for view-aligned snapping.
Apply to VStack or HStack inside a ScrollView.
ModifierConfigSee: Official SwiftUI documentation.
Specifies the label to display in the keyboard's return key. For example, 'done'.
ModifierConfigA view that uses the specified submit label.
Example
<TextField modifiers={[ submitLabel('search'), ]} />
Sets a transform for the case of the text contained in this view when displayed.
ModifierConfigSee: Official SwiftUI documentation.
Sets the text content type for input text, which the system uses to offer suggestions (like autofill) while the user enters text.
ModifierConfigSee: Official SwiftUI documentation.
Sets the text field style for text field views.
ModifierConfigSee: Official SwiftUI documentation.
Sets how often the shift key in the keyboard is automatically enabled.
ModifierConfigSee: Official SwiftUI documentation.
Controls whether people can select text within this view.
ModifierConfigSee: Official SwiftUI documentation.
Sets the style for toggles within this view.
ModifierConfigSee: Official SwiftUI documentation.
Sets the truncation mode for lines of text that are too long to fit in the available space.
ModifierConfigSee: Official SwiftUI documentation.
Specifies the how to render an Image when using the WidgetKit/WidgetRenderingMode/accented mode.
ModifierConfigSee: Official SwiftUI documentation.
Sets the URL to open in the containing app when the user clicks the widget. Widgets support one widgetURL modifier in their view hierarchy. If multiple views have widgetURL modifiers, the behavior is undefined.
ModifierConfigSee: Official SwiftUI documentation.
Sets the z-index (display order) of a view.
ModifierConfigSee: Official SwiftUI documentation.
Event subscriptions
Creates a modifier with an event listener.
ModifierConfigInterfaces
Base interface for all view modifiers. All modifiers must have a type field and can include arbitrary parameters.
Types
Literal type: string
Acceptable values are: 'automatic' | 'compact' | 'graphical' | 'wheel'
Type: object shaped as below:
Or object shaped as below:
Or object shaped as below:
Or object shaped as below:
Literal type: string
Acceptable values are: 'automatic' | 'circular' | 'circularCapacity' | 'linear' | 'linearCapacity'
Literal type: string
Acceptable values are: 'automatic' | 'plain' | 'inset' | 'insetGrouped' | 'grouped' | 'sidebar'
Literal type: string
Acceptable values are: 'automatic' | 'inline' | 'menu' | 'navigationLink' | 'palette' | 'segmented' | 'wheel'
Presentation background interaction type.
Type: 'automatic' or 'enabled' or 'disabled' or object shaped as below:
Presentation detent type for controlling sheet heights.
'medium': System medium height (approximately half screen)'large': System large height (full screen){ fraction: number }: Fraction of screen height (0-1, for example, 0.4 equals to 40% of screen){ height: number }: Fixed height in points
Type: 'medium' or 'large' or object shaped as below:
Or object shaped as below:
Literal type: string
Acceptable values are: 'automatic' | 'linear' | 'circular'
Literal type: ReturnType
Acceptable values are: ReturnType<shapes.roundedRectangle> | ReturnType<shapes.capsule> | ReturnType<shapes.rectangle> | ReturnType<shapes.ellipse> | ReturnType<shapes.circle>