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

PropTypeDefaultDescription
checkedboolean
defaultCheckedbooleanfalse
onCheckedChange(checked: boolean) => void
labelstringVisible label. Without one, pass `aria-label`.
descriptionstring
styleStyleProp<ViewStyle>
nativebooleanRenders the real platform control when `@leoanimesh/ferrule-native` is available.