# Switch — React Native component for Expo

> A toggle whose thumb squashes and stretches toward the other side while held.

A toggle whose thumb stretches toward the other side while you hold it (squash & stretch), drags across under your finger and throws a soft halo as it springs over, while the track cross-fades. iOS, Material 3 and sun/moon icon looks.

- Docs: https://expokit.in/docs/components/switch
- Tier: Free
- Also called: toggle switch, iOS switch, on / off toggle
- Category: Selection
- Platforms: iOS, Android, web
- Expo Go: yes, no development build needed
- npm dependencies: react-native-svg, expo-haptics
- Uses ExpoKit items: kit
- Variants: IOS, Material, Icons, Settings Rows, Sizes

## Installation

Run once per project: `npx @expokit/cli@latest init` (shared theme + KitProvider). Then:

```bash
npx @expokit/cli@latest add switch
```

The CLI copies the source into your project (you own the code) and installs react-native-svg, expo-haptics.

Import: `import { Switch } from "@/components/ui/switch";`

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `value / onValueChange` | `boolean` | — | Controlled state (or use defaultValue). |
| `defaultValue` | `boolean` | `false` | Initial state when uncontrolled. |
| `variant` | `"ios" \| "material" \| "icon"` | `"ios"` | Look of the track and thumb. |
| `size` | `"sm" \| "md" \| "lg"` | `"md"` | 24 / 31 / 38pt tall. |
| `icon` | `"theme" \| "check"` | `"theme"` | Sun / moon or ✕ / check inside the thumb (variant="icon"). |
| `label` | `string` | — | Turns it into a settings row with the switch on the right. |
| `description` | `string` | — | Secondary line under the label. |
| `accent` | `string` | `theme accent` | Track colour when on. |
| `haptics` | `boolean` | `true` | Light tap when it flips. |
| `disabled` | `boolean` | `false` | Dims and blocks presses. |
| `style` | `StyleProp<ViewStyle>` | — | Style for the pressable — the switch itself, or the whole settings row when label is set. |
| `className` | `string` | — | Tailwind classes on the root when using NativeWind or Uniwind. Prefer style for StyleSheet overrides. |

## Behaviour & accessibility

- **Touch**: Tap to flip, or drag the thumb across. Passing label (and description) turns it into a settings row.
- **Motion**: The thumb stretches toward its destination while pressed, springs over with a soft halo, and the track cross-fades.
- **Haptics**: A light impact on every flip; turn it off with haptics={false}.
- **Screen readers**: A switch role with checked and disabled state, labelled by accessibilityLabel or label.

## FAQ

### How do I make a toggle switch in React Native?

Use ExpoKit's Switch: run npx @expokit/cli@latest add switch in your Expo or React Native project and it copies a ready-made toggle switch into your app as plain TypeScript you can edit. It works on iOS, Android and web, and in Expo Go.

### Does Switch work in Expo Go?

Yes. Switch runs in Expo Go on iOS and Android with no development build — its packages (react-native-svg, expo-haptics) are all included in Expo Go.

### How do I add Switch to my Expo app?

Run npx @expokit/cli@latest add switch in your project. The CLI copies the component's source into your app and installs react-native-svg, expo-haptics, so the code is yours to change.

### Is Switch free?

Yes. Switch is free: its full source is on this page and the CLI installs it without an account.

### Can I change how Switch looks?

Yes. It takes its colours, radius and light / dark mode from useKit(), so wrapping your app in <KitProvider accent radius> re-skins it with every other ExpoKit component. The code lives in your project, so you can also edit anything directly.

## More

- Live preview, variants and code: https://expokit.in/docs/components/switch
- Every ExpoKit component, screen, template and chart: https://expokit.in/llms.txt
- Install commands and props for every free component: https://expokit.in/llms-full.txt
- Pricing: https://expokit.in/pricing
