Glass Toggle — a light and dark mode switch in three.js

One glass light and dark mode switch rendered live. Tap it, press Enter or Space, or grab the pearl and throw it. When the pearl hits the far wall, the new mode washes out from the impact across the toggle and the page. Requires WebGL 2.

ZirkoMirko

Polishing the glass…

What is Glass Toggle?

Glass Toggle is a free three.js toy by ZirkoMirko: a single light and dark mode switch made of glass, with an iridescent pearl in light mode and a glowing plasma core in dark mode. When the pearl hits the far wall, the new mode spreads from the impact across the toggle and the page. Everything is rendered live in the browser.

How it works

  1. Tap or click the toggle, or press Enter or Space, to flick the pearl across.
  2. Grab the pearl and drag or throw it; it bounces off the walls.
  3. When the pearl hits the far wall, the new mode washes out from the impact.

FAQ

Is it a real dark mode switch?
It is a toy, not a component: it switches its own page between light and dark, and the pearl and colours are rendered in WebGL.
What does my browser need?
Glass Toggle requires JavaScript and WebGL 2.