Switch
Switch, a React Native component for iOS, Android and web: A drawn on and off control.
Usage
import { useState } from 'react';
import { Stack } from './components/ui/stack';
import { Switch } from './components/ui/switch';
export default function Example() {
const [on, setOn] = useState(true);
return (
<Stack gap={3} style={{ maxWidth: 360 }}>
<Switch label="Order updates" description="Tell me when the rider leaves" checked={on} onCheckedChange={setOn} />
<Switch label="Marketing email" defaultChecked={false} />
<Switch label="Managed by your admin" checked disabled />
</Stack>
);
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
checked | boolean | ||
defaultChecked | boolean | false | |
onCheckedChange | (checked: boolean) => void | ||
label | string | Visible label. Without one, pass `aria-label`. | |
description | string | ||
style | StyleProp<ViewStyle> | ||
native | boolean | Renders the real platform control when `@leoanimesh/ferrule-native` is available. |