1. Docs
  2. Components
  3. Switch

Switch

A control that allows the user to toggle between on and off.

Installation

npx shadcn@latest add @kanpeki/switch

Anatomy

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

<Switch.Root>
  <Switch.Track>
    <Switch.Thumb />
  </Switch.Track>
</Switch.Root>

Examples

Group

Form

Component switch-form not found in registry.

API Reference

Root

PropTypeDefault
defaultSelected
boolean
false
isSelected
boolean
false
onChange
function