Liquid glass
A three-way theme switcher rendered as a frosted glass pill: an SVG filter (feImage + feGaussianBlur + feDisplacementMap, driven by an embedded lens-distortion map) is applied through backdrop-filter: blur(8px) url(#…) saturate(…) so the content scrolling underneath actually refracts through the glass, not just blurs.
Every theme swaps a set of CSS custom properties — background, content color, action color, and two “glass reflex” strengths used across the pill’s inset box-shadow layers — scoped here to the pen’s own preview stage via :has() rather than the page’s body, so switching themes never leaks past this card.
The pill remembers which option it came from, so it always slides the short way.
That direction comes from a tiny piece of state: each time a new option is chosen, the previously selected option is recorded, and a CSS selector picks the sliding pill’s transform-origin based on whether the new option sits to the left or right of the old one.
Try switching between Light, Dark, and Dim — the glass reflections, the pill’s glide direction, and every color on this card update together.
Built on native CSS
No JavaScript animation library: color-mix() blends the reflex layers, :has() drives both the theme swap and the pill’s per-option position, and the icons scale on hover with a plain cubic-bezier transition.