Text
A component for displaying styled text content.
For the complete documentation index, see llms.txt. Use this file to discover all available pages.
A component for displaying text. Adapts to the platform color scheme (light/dark) by default and exposes a focused subset of typography knobs through textStyle.
Installation
- npx expo install @expo/uiIf you are installing this in an existing React Native app, make sure to install expo in your project.
Usage
Basic text
import { Host, Text } from '@expo/ui'; export default function TextExample() { return ( <Host matchContents> <Text>Hello, world!</Text> </Host> ); }
Styled text
Use textStyle for typography-specific properties (font size, weight, alignment).
import { Host, Text } from '@expo/ui'; export default function StyledTextExample() { return ( <Host matchContents> <Text textStyle={{ fontSize: 24, fontWeight: '700', textAlign: 'center' }}>Headline</Text> </Host> ); }
Truncating long text
Use numberOfLines to clamp long text with a trailing ellipsis.
import { Host, Text } from '@expo/ui'; export default function TruncatedTextExample() { return ( <Host style={{ flex: 1 }}> <Text numberOfLines={1}> A very long line of text that will be truncated when it does not fit on a single line. </Text> </Host> ); }
API
import { Text } from '@expo/ui';
Component
Type: React.Element<TextProps>
A component for displaying styled text content.
Props for the Text component.
booleanWhether the component is disabled. Disabled components do not respond to user interaction.
ModifierConfig[]Platform-specific modifier escape hatch. Pass an array of modifier configs
from @expo/ui/swift-ui/modifiers or @expo/ui/jetpack-compose/modifiers.
numberMaximum number of lines to display. Text is truncated with an ellipsis when exceeded.
() => voidCalled when the component is removed from screen.
Pick<ViewStyle, 'padding' | 'paddingHorizontal' | 'paddingVertical' | 'paddingTop' | 'paddingBottom' | 'paddingLeft' | 'paddingRight' | 'backgroundColor' | 'borderRadius' | 'borderWidth' | 'borderColor' | 'opacity' | 'width' | 'height'>Platform-agnostic style properties. These are translated to SwiftUI modifiers on iOS and Jetpack Compose modifiers on Android.
stringIdentifier used to locate the component in end-to-end tests.
{
color: string,
fontFamily: string,
fontSize: number,
fontWeight: 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900',
letterSpacing: number,
lineHeight: number,
textAlign: 'center' | 'left' | 'right'
}Text-specific styling (font, color, alignment).