This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
This is documentation for the next SDK version. For up-to-date documentation, see the latest version (SDK 57).
按钮
用于显示原生 Material3 按钮的 Jetpack Compose 按钮组件。
有关跨平台用法,请参见通用的
Button—— 它会针对每个平台渲染相应的原生组件。
Expo UI 提供了五个按钮组件,与官方 Jetpack Compose Button API 保持一致:Button(填充)、FilledTonalButton、OutlinedButton、ElevatedButton 和 TextButton。所有变体都共享相同的 props,并接受可组合子元素作为内容。


安装
If you are installing this in an existing React Native app, make sure to install expo in your project.
用法
基础按钮
填充按钮是用于主要操作的默认高强调按钮。
按钮变体
使用不同的按钮组件来传达不同级别的强调程度。
带图标的按钮
由于按钮接受可组合子元素,你可以使用 Icon 组件添加前置和后置图标。这遵循 带图标的 Material 3 按钮 模式(官方示例),使用 18dp 的图标尺寸,以及图标和标签之间 8dp 的间距。
自定义颜色
使用 colors 属性覆盖容器颜色和内容颜色。
自定义形状
API
import { Button, FilledTonalButton, OutlinedButton, ElevatedButton, TextButton, } from '@expo/ui/jetpack-compose';
Components
Type: React.Element<ButtonProps>
A filled button component.
ButtonContentPaddingThe padding between the button container and its content. Use this to adjust internal spacing, for example when adding a leading icon
boolean • Default: trueWhether the button is enabled for user interaction.