Shader interaction

Meniscus

A dark mode switch that takes a second and a half and shows its working. Press the sun, and a band of coloured glass rises through the page and pours it into the other theme.

This page switches between light and dark the long way round. Press the sun, or the button below, and the theme doesn't fade. A band of coloured glass rises through the text, smears each line into red, green and blue copies, and pours the page into the dark.

At rest, everything here is ordinary text. You can select it, and it leans toward your cursor. WebGL only takes over for the second and a half the switch takes. Open Edit Shader to scrub through it frame by frame and change how the glass bends.

Why this one

A theme toggle is the smallest interaction on most sites. You press it and the colours swap, or at best fade. I wanted to see how much a single tap could carry if the switch itself was the moment. It's also a test of a hand-off I wanted to get right: real, selectable text that becomes shader pixels for a second and a half, then goes back to being text without a visible seam.

The Boring Version

A sun and a moon icon, and a 200 ms cross-fade from white to near-black. It works, and nobody remembers it.

My Version

Going to dark, an iridescent band rises from the bottom of the page. The text above it smears into red, green and blue copies. Behind it, a mint crown lights the top while dark ink fills the page from below and the text sinks out of focus. Then the dark theme settles and the blur clears from the top down. Going back to light runs the other way: the light pours in from above and the band sweeps down.

The small details

One tap, five things happening.

01 / Live text until it isn't

At rest the page is ordinary HTML. You can select it, and it tilts toward your cursor. When you flip, the tilt eases back to flat first. Then every word is redrawn into a texture, in exactly the box the browser laid it out in. The shader takes over, and when the flip lands, the HTML comes back in the new theme.

02 / The meniscus

The band is a curved front, arched in the direction it travels. It's banded lilac, violet, cyan and mint, with its wings brighter than its centre so the text still shows through the middle. Inside the band the text is magnified toward its spine, like type seen through the curve of a water glass.

03 / RGB echo

Ahead of the band, each line is copied sixteen times, each copy pulled further down and tinted along the spectrum. Up close the lines turn into coloured streaks. Text the band has already passed keeps a pink and cyan fringe for a moment.

04 / Bokeh settle

The new theme floods in from an ellipse, with a thin bright lip along its edge. Text inside it goes out of focus, then sharpens again from the top down: the first paragraph, then the second, then the button.

05 / The inspector

Edit Shader opens the controls. Scrub the progress by hand, jump to any of the named keyframes, swap the colour presets, or bend the glass. It also shows the GLSL, and copies your settings as JSON. The button in the bottom corner opens the whole stage full screen, which is the best way to watch a flip.