Components
- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Avatar
- Badge
- Breadcrumb
- Button
- Button Group
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Collapsible
- Combobox
- Command
- Context Menu
- Data Table
- Date Picker
- Dialog
- Drawer
- Dropdown Menu
- Empty
- Field
- Hover Card
- Input
- Input Group
- Input OTP
- Item
- Kbd
- Label
- Menubar
- Native Select
- Navigation Menu
- Pagination
- Popover
- Progress
- Radio Group
- Resizable
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toggle
- Toggle Group
- Tooltip
- Typography
import { Switch } from "@/components/ui/switch";
export function SwitchDemo() {
return (
<label style={{ alignItems: "center", display: "flex", gap: 8 }}>
<Switch defaultChecked />Installation
$ pnpm dlx shadcn@latest add https://shadcn-cssinjs.com/r/switch.json
Usage
import { Switch } from "@/components/ui/switch/switch";<Switch defaultChecked />Examples
Description
Focus is shared across devices, and turns off when you leave the app.
import {
Field,
FieldContent,
FieldDescription,
FieldLabel,
} from "@/components/ui/field";Choice Card
import {
Field,
FieldContent,
FieldDescription,
FieldGroup,
FieldLabel,Disabled
import { Field, FieldLabel } from "@/components/ui/field";
import { Switch } from "@/components/ui/switch";
export function SwitchDisabled() {
return (
<Field className="w-fit" data-disabled orientation="horizontal">Invalid
You must accept the terms and conditions to continue.
import {
Field,
FieldContent,
FieldDescription,
FieldLabel,
} from "@/components/ui/field";Size
import {
Field,
FieldGroup,
FieldLabel,
} from "@/components/ui/field";
import { Switch } from "@/components/ui/switch";RTL
To enable right-to-left support, see the RTL guide.
"use client";
import { useTranslation } from "@/components/language-selector";
import type { Translations } from "@/components/language-selector";
import { Switch } from "@/components/ui/switch";
API Reference
See the Base UI documentation for the full API.