This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
开关
用于切换控制的 Jetpack Compose 开关组件。
Android
Included in Expo Go
有关跨平台用法,请参阅通用的
Switch—— 它会针对每个平台渲染相应的原生组件。
Expo UI Switch 与官方 Jetpack Compose Switch API 一致。


安装
Terminal
If you are installing this in an existing React Native app, make sure to install expo in your project.
使用
切换开关
ToggleSwitchExample.tsx
自定义颜色
CustomColorsExample.tsx
自定义拇指内容
使用 Switch.ThumbContent 在拇指内部渲染自定义元素。Switch.DefaultIconSize 会提供 M3 默认图标大小,使你的内容恰好适配。
ThumbContentExample.tsx
API
import { Switch } from '@expo/ui/jetpack-compose';
Components
Type: React.Element<SwitchProps>
A switch component.
Optional • Type:
(value: boolean) => voidCallback function that is called when the checked state changes.
Type: React.Element<ThumbContentProps>
Custom content to be displayed inside the switch thumb.