Switch

A toggle whose thumb slides with a double bounce, with hover and press states and geometry you can resize from CSS variables

import { Switch } from "@/components/ui/switch";
export default function SwitchDemo() {
return (
<label className="flex items-center gap-3 text-sm">
<Switch defaultChecked />
Airplane mode
</label>
);
}

Installation

npx shadcn@latest add https://www.deltacomponents.dev/r/switch.json

Usage

1import { Switch } from "@/components/ui/switch";
2
3<Switch defaultChecked />

It is Base UI's Switch underneath, so it carries the switch role, full keyboard support, and a form name/value for free. The thumb's travel is a keyframe sequence that plays only on a change, never on mount.

Basic

import { Switch } from "@/components/ui/switch";
export default function SwitchDemo() {
return (
<label className="flex items-center gap-3 text-sm">
<Switch defaultChecked />
Airplane mode
</label>
);
}

Disabled

import { Switch } from "@/components/ui/switch";
export default function SwitchDisabled() {
return (
<div className="flex items-center gap-6">
<label className="flex items-center gap-3 text-sm">
<Switch disabled />
Off
</label>
<label className="flex items-center gap-3 text-sm">
<Switch disabled defaultChecked />
On
</label>
</div>
);
}

Sizes

sm is Ant Design's small switch (28×16), the default its 44×22, and lg the default at iOS's 51×31 proportion. The thumb is iOS 26's at every step: a wide pill filling most of the track's height behind a thin inset.

import { Switch } from "@/components/ui/switch";
export default function SwitchSizes() {
return (
<div className="flex items-center gap-6">
<Switch size="sm" defaultChecked aria-label="Small" />
<Switch defaultChecked aria-label="Default" />
<Switch size="lg" defaultChecked aria-label="Large" />
</div>
);
}

Override Styling

Every size is a handful of CSS variables on the root, so a style can set a geometry of its own and the travel, hover pill and press squash follow:

Parts you hold no reference to are reachable by data-slot:

API Reference