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.