This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
Switch
用于切换控件的 Jetpack Compose Switch 组件。
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.