Switch

Switch on Base UI whose thumb stretches on press then springs across, with sm and default sizes, a loading spinner state and an optional clickable label row.

src/registry/ui/switch.tsx/r/switch.json

Email notifications

Sent to billing@lumen.app

2 of 4 on

Press and hold, then release

Off / on / loading / disabled

Installation#

bash
npx shadcn@latest add @minidev/switch

MiniDev UI is in the shadcn registry directory, so the short form works with no setup. Older CLI versions can use the full URL: npx shadcn@latest add https://ui.minidev.pro/r/switch.json

Usage#

tsx
import { Switch } from "@/components/ui/switch"

export function Example() {
  return (
    <Switch aria-label="Off" />
  )
}

API reference#

Switch props
PropTypeDefault
sizeSize"default"
loadingbooleanfalse
labelReact.ReactNode-
descriptionReact.ReactNode-

Also accepts every prop of SwitchPrimitive.Root props, passed through to the root element.

Dependencies#

npm

@base-ui/reactlucide-reactmotion

Built from

No other MiniDev files

Examples#

All form components

Learn more