← Lab004 · Liquid menu

Lab 00430 Oct 2026

Liquid menu

A menu painted by a tiny GPUI-style renderer in WebGPU. The links are real HTML; the boxes under them are distance fields, so they melt into each other.

How it works

Zed’s editor is drawn by GPUI, which turns every box into data for one small shader per kind of primitive: rounded rectangles as signed distance fields, drop shadows in closed form. This is the same idea in a few hundred lines of raw WebGPU, with no library.

The browser stays in charge of what it’s good at. The menu is a real nav of links, laid out by CSS, with real focus and keyboard support. Each frame the painter reads the boxes it was handed, moves a spring-driven shape towards each one, and draws every shape in a single full-screen pass, clipped to the area they cover.

Because the shapes are distance fields, not CSS boxes, two of them can be smoothly unioned: when they come close, a neck of liquid grows between them. That’s the whole trick. The drop spills into a pool, a drip hangs off the bottom, and whichever item you point at swells out into a lens joined to the pool.

The shadows use Evan Wallace’s rounded-rectangle method: the Gaussian blur is exact along one axis with the error function and sampled four times along the other, so a soft shadow costs the same at any size. The surface is shaded like Lab 001’s black chrome, with your pointer as a small lamp, and the lens bends the experiment’s own preview video.

Recreate it

A prompt you can paste into a coding agent to build your own.

Build a website menu whose background is painted by a tiny GPUI-style renderer in raw WebGPU, as a single HTML file.

- Keep the menu real HTML: a button with aria-expanded, a nav of links, focus, arrow keys and Escape. A full-screen canvas sits under the links with pointer-events off.
- Each frame, read the bounding boxes of the button, the nav and the hovered link. Drive a set of shapes (drop, stem, pool, drips, neck, lens) towards them with springs.
- Upload the shapes to a storage buffer and draw them in one full-screen WGSL pass, scissored to their bounds: rounded-rect signed distance fields joined with a smooth minimum, so nearby shapes melt together.
- Shade the field like black ferrofluid: normal from the gradient, a fake studio of softboxes, the pointer as a lamp. Add Evan Wallace's closed-form rounded-rectangle shadows.
- The hovered item swells into a round lens beside the pool, showing that item's preview video (copyExternalImageToTexture), magnified with a little chromatic fringe.
- Without WebGPU, show the same menu as a flat dark panel.

How it happened

The real conversation, shortened. Charul’s words are in quotes; everything else is a summary of what happened.

  1. Charul

    We need to build something which is related to WebGPU based GPUI, research on it first.

  2. Claude

    Researched how Zed’s GPUI draws its UI, WebGPU support in 2026 and Chrome’s new HTML-in-Canvas API, then pitched three directions.

  3. Charul

    A functional, like a menu for the lab.

  4. Claude

    Mocked up three stills of a lab menu: a liquid drop, microscope slides and a phosphor oscilloscope.

  5. Charul

    Asked for something WebGPU doesn’t have yet.

  6. Claude

    Wrote a tiny GPUI-style painter in raw WebGPU, with DOM layout and GPU paint, and built the liquid menu with it.