Controls
Glass Switch
An on/off switch whose knob turns to glass and stretches as it slides.
pnpm dlx shadcn@4.14.1 add @glassyui/glass-switchPreview
Demos ready. Update 0.
Installation
First add the exact @glassyui mapping to components.json as shown in Getting Started. Then run the pinned item command:
pnpm dlx shadcn@4.14.1 add @glassyui/glass-switchWhat this installs7 files, 2 packages
Direct registry declarations
These values belong to @glassyui/glass-switch itself in registry.json.
Package dependencies
@radix-ui/react-switchclsx
Registry dependencies
@glassyui/glass-provider
File targets
components/glassyui/glass-switch.tsxcomponents/glassyui/lib/merge-refs.tscomponents/glassyui/lib/liquid-motion.ts
Complete installed closure
This follows every namespaced registry dependency recursively and de-duplicates the packages and target files installed with this item.
Package dependencies
@radix-ui/react-switchclsx
Installed files
components/glassyui/glass-switch.tsxcomponents/glassyui/lib/merge-refs.tscomponents/glassyui/lib/liquid-motion.tscomponents/glassyui/glass-provider.tsxcomponents/glassyui/liquid-filters.tsxcomponents/glassyui/lib/preferences.tscomponents/glassyui/styles/liquid.css
Usage
import { GlassSwitch } from "@/components/glassyui/glass-switch";
export function SwitchDemo() {
return <GlassSwitch aria-label="Notifications" defaultChecked />;
}Examples
<label className="flex items-center justify-between gap-4">
Autosave
<GlassSwitch />
</label><GlassSwitch aria-label="Mute" size="sm" />API
GlassSwitchForward-ref Radix Switch root with a glass thumb.
GlassSwitchPropsRadix Switch root props plus size.
sizeTrack size: sm or md. Defaults to md.
checked / defaultCheckedControlled or uncontrolled on state.
onCheckedChangeCalled with the next checked value.
Notes
Accessibility
Renders a button with role switch. Name it with aria-label or wrap it in a visible label.
Motion
The knob turns to clear glass while pressed and stretches like a drop as it slides. Reduced motion keeps the colour change and drops the travel.
Accessibility
Keep the Radix-backed semantics intact and preserve visible labels, focus states, and keyboard operation when copying the source.
Performance
Use provider quality preferences for dense app screens. Reserve strong refraction for hero or showcase surfaces.