Liquid Glass Switch
A Liquid Glass-styled toggle switch with a capsule track, concentric circular thumb, optional dragging, and explicit material fallback controls.
Liquid Glass Switch pairs a capsule track with a concentric sliding thumb, applying a tinted on-state fill with optional pointer dragging, RTL mirroring, and an explicit material="opaque" fallback mode.
Preview
Section titled “Preview” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<div class="flex flex-wrap items-center gap-6">
<div class="inline-flex items-center gap-2.5">
<proto-ui-liquid-glass-switch-root material="auto">
<proto-ui-liquid-glass-switch-thumb></proto-ui-liquid-glass-switch-thumb>
<span class="sr-only">Airplane Mode</span>
</proto-ui-liquid-glass-switch-root>
<span class="text-sm font-medium">Airplane Mode</span>
</div>
<div class="inline-flex items-center gap-2.5">
<proto-ui-liquid-glass-switch-root
default-checked
material="auto"
>
<proto-ui-liquid-glass-switch-thumb></proto-ui-liquid-glass-switch-thumb>
<span class="sr-only">Release alerts</span>
</proto-ui-liquid-glass-switch-root>
<span class="text-sm font-medium">Release alerts</span>
</div>
<div class="inline-flex items-center gap-2.5">
<proto-ui-liquid-glass-switch-root disabled>
<proto-ui-liquid-glass-switch-thumb></proto-ui-liquid-glass-switch-thumb>
<span class="sr-only">Archived alerts</span>
</proto-ui-liquid-glass-switch-root>
<span class="text-sm font-medium">Archived alerts</span>
</div>
</div>Installation
Section titled “Installation”Currently available from Proto UI workspace source via @proto.ui/prototypes-liquid-glass/switch.
import { switchRoot, switchThumb } from '@proto.ui/prototypes-liquid-glass/switch';<proto-ui-liquid-glass-switch-root default-checked> <proto-ui-liquid-glass-switch-thumb></proto-ui-liquid-glass-switch-thumb> <span class="sr-only">Enable notifications</span></proto-ui-liquid-glass-switch-root>- Material & layering:
material="auto"requestsliquid-glasswhen an in-app backdrop source is available. Setmaterial="opaque"inside glass containers or dense forms to avoid stacking glass on glass. - Accessibility & fallbacks: Track and thumb transitions automatically disable under
prefers-reduced-motion: reduce. Disabled switches withdraw optical material while preserving legible opaque contrast, and Reduced Transparency / Increased Contrast automatically fall back to the opaque surface.
Examples
Section titled “Examples”Description
Section titled “Description” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<proto-ui-liquid-glass-field-root
class="flex max-w-sm flex-row items-center justify-between gap-4"
>
<div class="flex min-w-0 flex-1 flex-col gap-1">
<proto-ui-liquid-glass-field-label>
Share across devices
</proto-ui-liquid-glass-field-label>
<proto-ui-liquid-glass-field-description>
Focus is shared across devices, and turns off when you leave
the app.
</proto-ui-liquid-glass-field-description>
</div>
<proto-ui-liquid-glass-field-switch>
<proto-ui-liquid-glass-switch-thumb></proto-ui-liquid-glass-switch-thumb>
</proto-ui-liquid-glass-field-switch>
</proto-ui-liquid-glass-field-root>Material
Section titled “Material”Compare the default material="auto" surface with an explicit material="opaque" opt-out.
Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<proto-ui-liquid-glass-field-root
class="flex max-w-sm flex-row items-center justify-between gap-4"
>
<div class="flex min-w-0 flex-1 flex-col gap-1">
<proto-ui-liquid-glass-field-label>
Opaque surface
</proto-ui-liquid-glass-field-label>
<proto-ui-liquid-glass-field-description>
Opts out of translucency for dense forms or glass containers.
</proto-ui-liquid-glass-field-description>
</div>
<proto-ui-liquid-glass-field-switch
material="opaque"
default-checked
>
<proto-ui-liquid-glass-switch-thumb></proto-ui-liquid-glass-switch-thumb>
</proto-ui-liquid-glass-field-switch>
</proto-ui-liquid-glass-field-root>Disabled
Section titled “Disabled” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<proto-ui-liquid-glass-field-root
disabled
class="flex max-w-sm flex-row items-center justify-between gap-4"
>
<div class="flex min-w-0 flex-1 flex-col gap-1">
<proto-ui-liquid-glass-field-label>
Disabled (off)
</proto-ui-liquid-glass-field-label>
</div>
<proto-ui-liquid-glass-field-switch>
<proto-ui-liquid-glass-switch-thumb></proto-ui-liquid-glass-switch-thumb>
</proto-ui-liquid-glass-field-switch>
</proto-ui-liquid-glass-field-root>Invalid
Section titled “Invalid” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<proto-ui-liquid-glass-field-root
invalid
class="flex max-w-sm flex-row items-center justify-between gap-4"
>
<div class="flex min-w-0 flex-1 flex-col gap-1">
<proto-ui-liquid-glass-field-label>
Accept terms and conditions
</proto-ui-liquid-glass-field-label>
<proto-ui-liquid-glass-field-description>
You must accept the terms and conditions to continue.
</proto-ui-liquid-glass-field-description>
</div>
<proto-ui-liquid-glass-field-switch>
<proto-ui-liquid-glass-switch-thumb></proto-ui-liquid-glass-switch-thumb>
</proto-ui-liquid-glass-field-switch>
</proto-ui-liquid-glass-field-root>Draggable & RTL
Section titled “Draggable & RTL” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<proto-ui-liquid-glass-field-root
dir="rtl"
class="flex max-w-sm flex-row items-center justify-between gap-4"
>
<div class="flex min-w-0 flex-1 flex-col gap-1">
<proto-ui-liquid-glass-field-label>
المشاركة عبر الأجهزة
</proto-ui-liquid-glass-field-label>
<proto-ui-liquid-glass-field-description>
يتم مشاركة التركيز عبر الأجهزة، ويتم إيقاف تشغيله عند مغادرة
التطبيق.
</proto-ui-liquid-glass-field-description>
</div>
<proto-ui-liquid-glass-field-switch
direction="rtl"
draggable
default-checked
>
<proto-ui-liquid-glass-switch-thumb></proto-ui-liquid-glass-switch-thumb>
</proto-ui-liquid-glass-field-switch>
</proto-ui-liquid-glass-field-root>The following props and events belong to Root (Thumb has no props):
| Prop / Event | Type | Default |
|---|---|---|
checked | boolean undefined | uncontrolled |
defaultChecked | boolean | false |
disabled | boolean | false |
draggable | boolean | false |
direction | 'ltr' 'rtl' | 'ltr' |
material | 'auto' 'opaque' | 'auto' |
checkedChange | event ({ checked: boolean }) | — |
focusSelf | method (options?: FocusRequestOptions) => void | — |