8bit

Search docs

Search for a docs page

Switch

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

Installation

pnpm dlx shadcn@latest add https://8bit.cnlibs.com/r/switch.json

Usage

import { Label } from "@/components/ui/label";
import { Switch } from "@/components/ui/switch";
<div className="flex items-center gap-2">
  <Switch defaultChecked id="airplane-mode" />
  <Label htmlFor="airplane-mode">Airplane Mode</Label>
</div>

Disabled

Set disabled to prevent the switch from being toggled.