This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
Button
用于显示原生 Material3 按钮的 Jetpack Compose Button 组件。
信息 跨平台使用请参阅通用
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 prop 覆盖容器和内容颜色。
自定义形状
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.