Switch

Switches allow users to turn an individual option on or off.

<Switch>
  <SwitchIndicator />
  <Label>Focus mode</Label>
</Switch>

Installation

npx shadcn@latest add @dotui/switch

Usage

Use switch for communicating activation (e.g. on/off states), while checkboxes are best used for communicating selection (e.g. multiple table rows). Switches, unlike checkboxes, can't have an error state.

import { Switch } from "@/components/ui/switch";
<Switch>Focus mode</Switch>

Playground

Use the controls below to experiment with different switch props and see the live preview and code update.

size
<Switch>
  <SwitchIndicator>
    <SwitchThumb />
  </SwitchIndicator>
  <Label>Airplane mode</Label>
</Switch>

API Reference

Switch

A switch allows a user to turn a setting on or off.

PropType
"default"
"sm" | "md" | "lg"
RefObject<HTMLInputElement | null>
boolean
boolean
boolean
boolean
ReactNode | function
function

Last updated on 1/13/2026

Built with passion by @mehdibha.