This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.

Switch

A toggle control that switches between on and off states.

Android
iOS
Web
Included in Expo Go
Recommended version:
~56.0.26

A controlled toggle. Pair value with onValueChange to manage state from React.

Installation

Terminal
- npx expo install @expo/ui
- yarn expo install @expo/ui
- pnpm expo install @expo/ui
- bun expo install @expo/ui

If you are installing this in an existing React Native app, make sure to install expo in your project.

Usage

Basic switch

SwitchExample.tsx
import { useState } from 'react'; import { Host, Switch } from '@expo/ui'; export default function SwitchExample() { const [enabled, setEnabled] = useState(false); return ( <Host matchContents> <Switch value={enabled} onValueChange={setEnabled} /> </Host> ); }

With label

When label is provided, the switch is rendered alongside its text in a labeled row.

LabeledSwitchExample.tsx
import { useState } from 'react'; import { Host, Switch } from '@expo/ui'; export default function LabeledSwitchExample() { const [notifications, setNotifications] = useState(true); return ( <Host style={{ flex: 1 }}> <Switch label="Enable notifications" value={notifications} onValueChange={setNotifications} /> </Host> ); }

API

import { Switch } from '@expo/ui';

No API data file found, sorry!