Switch
A switch whose handle becomes glass under your thumb.
LiquidGlassSwitch is self-contained in the same way as the slider — its own background, its own refracted track, no view and no capture anywhere near it.
Dart
LiquidGlassSwitch(
value: wifi,
onChanged: (v) => setState(() => wifi = v),
activeColor: const Color(0xFF0A84FF),
width: 64,
height: 28,
)| Parameter | Default | What it does |
|---|---|---|
value | — | On or off. |
onChanged | — | Fires on tap and on drag-release. |
activeColor | 0xFF34C759 | Track colour when on. |
inactiveColor | 0x4C787880 | Track colour when off. |
thumbColor | white | The contracted rest thumb. |
width / height | null | Shorthands for the same two fields on layout, and they win over them. They size the track, not the thumb. |
layout | LiquidGlassSwitchLayout() | Track and thumb geometry. Defaults to the iOS-26 63×28 capsule; everything else is derived from it. |
style | null | Overrides the handle glass. |
reserveSwellRoom | false | Reserves layout room for the press swell instead of letting it paint outside. Turn it on under a clipping ancestor. |
pixelRatio | 1.0 | Capture resolution for the inner view. |
The handle is not a picture of glass#
At rest the thumb is a solid pill and the lens beneath it contributes nothing — fully frosted, no bend, no rim. Press it and the solid dissolves as the optics come up together, so the glass arrives as a state change instead of being revealed behind a fading white. Hold one down and the track bends through it.
Comments
Comments are GitHub Discussions — reply from either place.