---
title: "Switch"
description: "A weighty thumb that squishes and stretches."
documentation: "https://beui.dev/react-native/switch"
markdown: "https://beui.dev/react-native/switch.md"
---

# Switch

> A weighty thumb that squishes and stretches.

React Native component for Expo, from beUI Native. Group: Forms. Variants: 1.

## Install

Set up beUI Native once per app first: https://beui.dev/docs/native-setup.md

```bash
npx beui-native add switch
```

Or copy the source by hand and install its libraries:

```bash
npx expo install react-native-reanimated react-native-worklets
npm install uniwind tailwindcss
```

## Links

- Source: https://github.com/starc007/beui-native/tree/main/src/components/switch
- Registry JSON with every file: https://beui.dev/native/r/switch
- Open in Expo Go: exp://u.expo.dev/93a3a95c-6dc2-4adb-b57c-efbecf859f25/--/switch?runtime-version=exposdk%3A58.0.0&channel-name=production
- Web version: https://beui.dev/components/motion/switch.md

## README

### Switch

Native port of [beUI Switch](https://beui.dev/components/motion/switch). A toggle with a heavy spring-driven thumb and press feedback.

```tsx
import { Switch } from "./src";

<Switch checked={enabled} onCheckedChange={setEnabled} label="Enable notifications" />
<Switch defaultChecked label="Uncontrolled" />
<Switch accessibilityLabel="Airplane mode" />
<Switch size="sm" accessibilityLabel="Contactless" />
```

- **Motion:** the thumb travels on the web version's heavy spring (stiffness 800, damping 80, mass 4), so it feels weighty without wobbling. The track colour fades between `bg-muted/60` and `bg-primary` over 200 ms.
- **Press:** while pressed, the thumb shrinks to 90% and stretches 4 points toward where it is going.
- **Disabled:** dims to 60% opacity and ignores presses. On iOS and Android, pressing a disabled switch gives the thumb a small shake. On web the shake is skipped, because react-native-web needs the real `disabled` prop to report the disabled state.
- **State:** pass `checked` with `onCheckedChange` to control it, or `defaultChecked` to let it manage itself.
- **Size:** `size="md"` (the default) is a 48 × 28 track with a 20-point thumb. `size="sm"` is 40 × 24 with an 18-point thumb, for dense rows.
- **Label:** `label` renders text beside the track. The track and label form one touch target, and the label becomes the spoken name. Without a label, pass `accessibilityLabel`.
- **Accessibility:** reports the `switch` role with its checked and disabled states. `hitSlop` tops the track up to a 48-point touch area at either size.
- **RTL:** the thumb starts and travels from the leading edge.
- **Reduced motion:** when the system asks for it, or `disableAnimation` is set, the thumb and colour change instantly with no press squish or shake.

The web Switch only responds to taps, and so does this one. Native platform switches can also be dragged; that may come later with Gesture Handler.

Copy this directory, `hooks/use-reduced-motion.ts`, and the semantic tokens in `styles/theme.css`.
