This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
按钮
用于显示原生 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.