Skip to Content
Liquid Glass UI
Components

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 useVelocity and useSpring for organic squash-and-stretch during quick flicks and crisp threshold snapping on release.
  • Viewport responsive: Automatically switches between < 768px (iOS 27 wide 60×28px · Apple Green) and >= 768px (macOS 27 compact 40×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:

apple-liquid-ui/preview/switch-liquid-hero
MacBook · 16:10

Installation (Shadcn Registry)

# Install via the configured @apple-liquid namespace
npx shadcn@latest add @apple-liquid/switch

Color 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:

apple-liquid-ui/preview/switch-variants
MacBook · 16:10

Size Scale & Disabled States

Includes sm, default, and lg responsive sizes, disabled states, and keyboard focus rings:

apple-liquid-ui/preview/switch-sizes
MacBook · 16:10

Linked Settings Panel

Controlled checked / onCheckedChange example modeled after Apple System Settings where enabling Airplane Mode automatically disables Wi-Fi, Bluetooth, and AirDrop:

apple-liquid-ui/preview/switch-settings-panel
MacBook · 16:10

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:

PropTypeDefaultDescription
variant'default' | 'green' | 'blue''default'Active color; default adapts automatically by viewport (iOS Green ↔ macOS Blue)
glassbooleantrueTranslucent 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
showLabelsbooleanfalseShow Apple-style accessibility I / O track indicators
refractionnumber1Snell refraction multiplier for the dragged droplet lip
dispersionnumber0.055Subtle RGB chromatic dispersion at droplet edges (0 disables)
disableMotionbooleanfalseDisable liquid lens refraction and spring physics (respects prefers-reduced-motion)

On this page