Switch
Liquid Glass toggle switch inspired by Apple iOS 27 and macOS 27 that expands into a transparent refractive droplet on press or drag, interpolating track color live with velocity stretch.
Built on @base-ui/react/switch, LiquidLens, and motion/react to faithfully capture Apple iOS 27 and macOS 27 Liquid Glass switch physics:
- Refractive droplet press & drag: Clicking or pressing and dragging the thumb horizontally expands the white pill into a transparent optical lens (
LiquidLens) that bends the underlying track and backdrop while smoothly interpolating track color. - Velocity stretch & spring snap: Combines Motion
useVelocityanduseSpringfor organic squash-and-stretch during quick flicks and crisp threshold snapping on release. - Viewport responsive: Automatically switches between
< 768px(iOS 27 wide60×28px· Apple Green) and>= 768px(macOS 27 compact40×22px· Apple Blue).
Liquid Glass Refractive Switch
Click to toggle, or press and drag the thumb slowly left and right to watch the refractive droplet bend the track edge and blend color in real time:
Installation (Shadcn Registry)
# Install via the configured @apple-liquid namespace
npx shadcn@latest add @apple-liquid/switchColor Variants & Accessibility Labels
Supports default (auto iOS Green ↔ macOS Blue), green, and blue variants, orthogonal glass translucent tracks, and Apple's I / O accessibility labels via showLabels:
Size Scale & Disabled States
Includes sm, default, and lg responsive sizes, disabled states, and keyboard focus rings:
Linked Settings Panel
Controlled checked / onCheckedChange example modeled after Apple System Settings where enabling Airplane Mode automatically disables Wi-Fi, Bluetooth, and AirDrop:
Usage
import { Switch } from '@/components/ui/switch';
import { Label } from '@/components/ui/label';
export function Example() {
return (
<div className="flex items-center gap-3">
<Switch id="liquid-mode" defaultChecked />
<Label htmlFor="liquid-mode">Enable Liquid Glass</Label>
</div>
);
}Props API
Switch
Supports all standard @base-ui/react/switch Switch.Root props (checked, defaultChecked, onCheckedChange, disabled, readOnly, name, required, etc.) plus:
| Prop | Type | Default | Description |
|---|---|---|---|
variant | 'default' | 'green' | 'blue' | 'default' | Active color; default adapts automatically by viewport (iOS Green ↔ macOS Blue) |
glass | boolean | true | Translucent Liquid Glass track and refractive droplet thumb on press/drag; false renders 100% opaque track and solid white thumb |
size | 'sm' | 'default' | 'lg' | 'default' | Responsive size scale calibrated for mobile and desktop |
showLabels | boolean | false | Show Apple-style accessibility I / O track indicators |
refraction | number | 1 | Snell refraction multiplier for the dragged droplet lip |
dispersion | number | 0.055 | Subtle RGB chromatic dispersion at droplet edges (0 disables) |
disableMotion | boolean | false | Disable liquid lens refraction and spring physics (respects prefers-reduced-motion) |
Spinner
Apple 27 Indeterminate Spinner with eight rounded spokes rotating in stepped cadence, sized 20px on mobile ↔ 16px on desktop, inheriting current text color for seamless embedding in buttons.
Table
Apple 27 Finder-style list table with hairline row dividers, subtle hover highlights, accent-tinted selected rows, and semibold secondary headers (15px mobile ↔ 13px desktop).