Components

Switch

Toggle switch component with optional label and size variants.

iOSAndroid
Preview Switch on your device

Scan with Expo Go

Download Expo Go, then scan the QR code to preview native components.

Installation

pnpm dlx @docyrus/cli add @docyrus/rn-switch

Usage

import { Switch } from '@/components/docyrus-native/switch';

<Switch checked={true} onCheckedChange={setChecked} />
<Switch label="Enable notifications" checked={on} onCheckedChange={setOn} />
<Switch size="sm" disabled />

API Reference

PropTypeDefaultDescription
checkedbooleanfalseSwitch state
onCheckedChange(value: boolean) => void—State change handler
disabledbooleanfalseDisable interaction
size'sm' | 'md' | 'lg''md'Switch size
labelstring—Optional label text
classNamestring—Additional CSS classes
labelClassNamestring—Label CSS classes
accessibilityLabelstring—Accessibility label

Type Exports

TypeDescription
SwitchPropsProps for Switch component
SwitchSize'sm' | 'md' | 'lg'

On this page