Components

Switch

A modern, animated toggle switch for selecting between two mutually exclusive states, optimized for mobile interactions.

Loading...

Installation

Install the registry item directly, then add any package dependencies if you are setting the component up manually.

1

Install the component

Run the registry command below to add switch to your project.

watermelon add switch
2

Install manual dependencies

If you are wiring the component manually, install the package dependencies shown below.

npm install react-native
3

Import the component

Import Switch from your local UI registry output.

Import

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

Import

Import

import { Switch } from "@/components/ui/switch"

Usage

The Switch component provides a familiar toggle interface. It uses React Native's Animated API for smooth thumb transitions and haptic-ready interactions.

Basic Usage

Use the switch as a controlled or uncontrolled component.

Loading...

Disabled State

The switch can be disabled in both checked and unchecked states.

Loading...

API Reference

Switch extends all supported props from React Native Pressable.

proptypedefaultdescription
checkedbooleanfalseThe controlled checked state of the switch.
onCheckedChange(checked: boolean) => void-Callback called when the checked state changes.
disabledbooleanfalseWhether the switch is interactive.
classNamestring-Standard Tailwind classes for the track.