Uqudo UIregistry

Switch

A control that lets the user toggle between checked and not checked.

Installation

npx shadcn@latest add @uqudo/switch

Usage

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

Pair it with a Label through id and htmlFor, and control it with checked and onCheckedChange:

<div className="flex items-center gap-2">
  <Switch
    id="notifications"
    checked={enabled}
    onCheckedChange={setEnabled}
  />
  <Label htmlFor="notifications">Notifications</Label>
</div>

Examples

Sizes

Disabled

API Reference

Switch

Prop

Type

Data attributes

AttributeElementValue
data-slotroot / thumbswitch / switch-thumb
data-sizerootThe resolved size.
data-stateroot / thumbchecked or unchecked (from Radix).
data-disabledroot / thumbPresent when disabled.

On this page