Expo App UIExpo App UI
Components

Switch

Animated toggle switch with three sizes and accessible switch role.

Installation

npx expo-app-ui add switch

Usage

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

const [on, setOn] = useState(false);
<Switch value={on} onValueChange={setOn} />

Props

PropTypeDefaultDescription
valuebooleanrequiredCurrent state
onValueChange(v: boolean) => voidrequiredChange handler
disabledbooleanfalseDisable interaction
size'sm' | 'md' | 'lg''md'Switch size
trackColorOnstring'#16A34A'Track color when on
trackColorOffstring'#D1D5DB'Track color when off
thumbColorstring'#FFFFFF'Thumb color
accessibilityLabelstring-Screen-reader label

Accessibility

  • accessibilityRole="switch"
  • accessibilityState={{ checked, disabled }}
  • 8px hit slop for easier touch targets

On this page

Find this useful?

Buy me a coffee