This is documentation for the next SDK version. For up-to-date documentation, see the latest version (SDK 54).
Button
A Jetpack Compose Button component for displaying native buttons.
Expo UI Button matches the official Jetpack Compose Button API and supports variants, icons, custom colors, and shapes.
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 button
import { Host, Button } from '@expo/ui/jetpack-compose'; export default function BasicButtonExample() { return ( <Host matchContents> <Button onPress={() => alert('Pressed!')}>Press me</Button> </Host> ); }
Button variants
Use the variant prop to change the button's appearance. Available variants are: default, bordered, borderless, outlined, and elevated.
import { Host, Button, Column } from '@expo/ui/jetpack-compose'; export default function ButtonVariantsExample() { return ( <Host matchContents> <Column verticalArrangement={{ spacedBy: 8 }}> <Button variant="default" onPress={() => {}}> Default </Button> <Button variant="bordered" onPress={() => {}}> Bordered </Button> <Button variant="borderless" onPress={() => {}}> Borderless </Button> <Button variant="outlined" onPress={() => {}}> Outlined </Button> <Button variant="elevated" onPress={() => {}}> Elevated </Button> </Column> </Host> ); }
API
import { Button } from '@expo/ui/jetpack-compose';
Component
Type: React.Element<ButtonProps>
Displays a native button component.
unionThe text to display inside the button.
Acceptable values are: string | string[] | React.JSX.Element
MaterialIconA string describing the leading icon to display in the button. Uses Material Icons on Android.
ShapeJSXElementDeprecated: Use
leadingIconinstead.
MaterialIconA string describing the system image to display in the button. Uses Material Icons on Android.
MaterialIconA string describing the trailing icon to display in the button. Uses Material Icons on Android.
Types
Colors for button's core elements.
| Property | Type | Description |
|---|---|---|
| containerColor(optional) | ColorValue | - |
| contentColor(optional) | ColorValue | - |
| disabledContainerColor(optional) | ColorValue | - |
| disabledContentColor(optional) | ColorValue | - |