Browse docsSwitch

Controls

Glass Switch

A glass on/off switch in two sizes.

Preview

Demos ready. Update 0.

Installation

For React 19+ apps with Tailwind CSS 4.

npx shadcn@4.14.1 add @glassyui/glass-switch

Adds 10 files to components/glassyui and installs @radix-ui/react-switch and clsx.

Usage

Usage

import { GlassSwitch } from "@/components/glassyui/glass-switch";

export function SwitchDemo() {
  return <GlassSwitch aria-label="Notifications" defaultChecked />;
}

Examples

With a visible label

<label className="flex items-center justify-between gap-4 select-none">
  Autosave
  <GlassSwitch />
</label>
Small

<GlassSwitch aria-label="Mute" size="sm" />

API reference

GlassSwitch

A button with role switch and a glass knob.

PropTypeDefaultDescription
size'sm' | 'md''md'Track size.
checked / defaultCheckedbooleanfalseControlled or uncontrolled on state.
onCheckedChange(checked: boolean) => voidNoneCalled with the next checked value.
disabledbooleanfalseStops the switch from toggling.
name / valuestring— / 'on'Submits the switch with a native form when checked.

Also accepts Radix Switch.Root props.

Types
GlassSwitchProps
Accessibility
Name the switch with aria-label or wrap it in a visible label element.