Forms & selection@neumorphism-ui/switch

Switch

Applies role=switch to a native checkbox input to preserve form and browser behavior. Supports checked, defaultChecked, and onCheckedChange.

@neumorphism-ui/switch
Registry JSON

Preview

Installation

Installation: switchnpx shadcn@latest add @neumorphism-ui/switch

The CLI resolves npm dependencies, base tokens, utilities, and component source in order.

New to this Registry? Set up the namespace before continuing.

Usage

Usage: Installationnpx shadcn@latest add @neumorphism-ui/switch @neumorphism-ui/label

Import

Switch import code
import { Switch } from "@/components/ui/switch"
import { Label } from "@/components/ui/label"

Example

Switch usage code
<div className="flex items-center justify-between gap-4">
  <Label htmlFor="system-theme">Use system theme</Label>
  <Switch id="system-theme" name="systemTheme" defaultChecked />
</div>

API Reference

ComponentPropTypeDefaultDescription
Switchchecked / defaultCheckedboolean—The controlled on state or initial uncontrolled state.
SwitchonCheckedChange(checked: boolean) => void—Called when the on state changes.
SwitchonChangeReact.ChangeEventHandler<HTMLInputElement>—Receives the native checkbox change event.
SwitchdisabledbooleanfalseDisables input and pointer interaction.
Switchname / value / requirednative input props—Native checkbox attributes used for form submission.

Accessibility

  • 01

    Applying role=switch to a real checkbox communicates the checked state to assistive technology and preserves Space key interaction.

  • 02

    Connect Label htmlFor to the Switch id, or provide an aria-label.

  • 03

    Checkbox may be more appropriate for a boolean choice that is not applied immediately and requires a separate save action.