Switch

On/off switch whose colour fills in from behind the thumb as it turns on. Turning off fades it back quickly, and a disabled switch gives a gentle flicker when tapped.

Preview

Props Changes apply to the live preview above.

Installation

npx @lumioui/cli add switch

Usage

import { Switch } from "@/components/ui/switch/switch";
<Switch />

Examples

Settings

A home-lighting schedule.

Standalone

One consequential toggle on its own card, the copy under it following the state; plus the built-in label prop and the disabled flicker when a toggle is locked by policy.

API reference

Prop Type Default
checked* boolean

Whether the switch is on.

—
onCheckedChange* (checked: boolean) => void

Called when the user toggles the switch.

—
disabled boolean

Disable interaction.

—
className string

Extra classes for the outer wrapper.

—
haptic "selection" | "light" | false

Haptic on toggle — default "selection". Set false to disable.

"selection"
label string

Optional label rendered to the left, switch trailing.

—
iconOn React.ReactNode

Optional icon rendered inside the thumb when on.

—