Controls

Switch

Preview
Reduced motion

Simulates prefers-reduced-motion for the demo. Off follows your system setting.

Keyboard stepping

Steps focus through the demo with ] and [. Tab, arrows, and Escape stay native so the component behaves as shipped.

Switch

Switch

An on and off switch whose thumb stretches as it travels.

Installation

npx shadcn@latest add ikislay/pixel-ui/switch

How to use

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

Source Code

// Loading…

Props

Options you can pass to customize this component.

Prop
Type
Description
checked
boolean

Controls the state. Leave it unset to let the switch manage itself.

defaultChecked
boolean

The starting state when uncontrolled.

onCheckedChange
(checked: boolean) => void

Called with the new state.

onFeedback
(event: "toggle") => void

Called at each semantic moment, for wiring sound or haptics.

className
string

Merged onto the root element.