Reference version

This is documentation for the next SDK version. For up-to-date documentation, see the latest version (SDK 54).

A Jetpack Compose Button component for displaying native buttons.

Android

A button component for displaying native buttons.

Installation

Terminal
npx expo install @expo/ui

If you are installing this in an existing React Native app, make sure to install expo in your project.

Usage

import { Button } from '@expo/ui/jetpack-compose'; <Button variant="default" leadingIcon="filled.Edit" onPress={() => { setEditingProfile(true); }}> Edit profile </Button> {/* Button with both leading and trailing icons */} <Button variant="bordered" leadingIcon="filled.Add" trailingIcon="filled.ArrowForward" onPress={() => console.log('Action')}> Add Item </Button>

See Official Jetpack Compose documentation for more information.

API

Component

Button

Android

Type: React.Element<ButtonProps>

Displays a native button component.

ButtonProps

children

Android
Optional • Literal type: union

The text to display inside the button.

Acceptable values are: string | string[] | React.JSX.Element

color

Android
Optional • Type: string

Button color.

disabled

Android
Optional • Type: boolean

Disabled state of the button.

elementColors

Android
Optional • Type: ButtonElementColors

Colors for button's core elements.

leadingIcon

Android
Optional • Type: MaterialIcon

A string describing the leading icon to display in the button. Uses Material Icons on Android.

modifiers

Android
Optional • Type: ExpoModifier[]

Modifiers for the component

onPress

Android
Optional • Type: () => void

A callback that is called when the button is pressed.

shape

Android
Optional • Type: ShapeJSXElement

style

Android
Optional • Type: StyleProp<ViewStyle>

Additional styles to apply to the button.

Deprecated Use leadingIcon instead.

systemImage

Android
Optional • Type: MaterialIcon

A string describing the system image to display in the button. Uses Material Icons on Android.

trailingIcon

Android
Optional • Type: MaterialIcon

A string describing the trailing icon to display in the button. Uses Material Icons on Android.

variant

Android
Optional • Type: ButtonVariant

The button variant.

Types

ButtonElementColors

Android

Colors for button's core elements.

PropertyTypeDescription
containerColor(optional)string
-
contentColor(optional)string
-
disabledContainerColor(optional)string
-
disabledContentColor(optional)string
-

ButtonVariant

Android

Literal Type: string

The built-in button styles available on Android.

  • outlined - A button with an outline.
  • elevated - A filled button with a shadow.

Acceptable values are: 'default' | 'bordered' | 'borderless' | 'outlined' | 'elevated'