- 01React renders real DOM
Ordinary inputs, buttons and text, with their state in React.
- 02The browser paints it into a canvas
HTML-in-Canvas captures each layer as a texture.
- 03One GPU pass composes it
Transforms, motion and your shaders on top.
| Question | View Transitions | Underglass |
|---|---|---|
| What moves | Images of the old and the new view | The page's own elements |
| While it runs | The view that leaves is a still image | Both views keep running: video plays, counters count |
| The effect | CSS animations on those images | Your shader on the pixels |
| You write | CSS for two pseudo-elements | Numbers, and WGSL when you want it |
00:00.0
This panel was under the first all along, as a layer of its own. The clock above and the button below are the page's elements, running, not a picture of them.
- React renderskipped
- Styleskipped
- Layoutskipped
- Paintskipped
- GPU drawone matrix
// Deal a hand: one call, 90 ms apart.
const deal = cards.map(card => (
{ id: card.id, motion: dealTo(card) }
));
gpu.transitionGroup(deal, 90);
import { defineEffect } from "@underglass/react";
export const sepia = defineEffect({
name: "sepia-glow",
parameters: { amount: { min: 0, max: 1 } },
geometry: "color", bounds: "layer",
capabilities: ["webgpu"],
wgsl: `
let r = dot(color.rgb, vec3f(0.393, 0.769, 0.189));
let g = dot(color.rgb, vec3f(0.349, 0.686, 0.168));
let b = dot(color.rgb, vec3f(0.272, 0.534, 0.131));
let tone = mix(color.rgb, vec3f(r, g, b), parameters.x);
return vec4f(tone, color.a);`,
});
- CSS
Flat and fast: gradients and shadows from the same tokens. What every browser gets.
- Relief
One shader lights every raised face, bevel and well from a single light.
- Objects
Buttons become keys that travel into their bezels; sliders, a rail with a puck.
- Instrument
Machined parts: knobs, faders and switches as lit meshes, with lamps that light the panel.
| Question | Ordinary DOM | GPU |
|---|---|---|
| Draws it | The browser, as usual | WebGPU, from live captures of the same elements |
| Where | Every browser | Chrome and Edge 157 or later |
| When | At startup, and whenever the GPU is off | After a check passes in this browser, in this window |
| Your code | The same components, state and event handlers | |
Underglass is experimental. Screen-reader testing, physical devices and wider browser qualification are still open.
import {
createCanvasHosts, mountCanvasApp, Surface,
} from "@underglass/react";
function Profile() {
return (
<Surface id="profile"
layout={{ x: 40, y: 40, width: 280, height: 160 }}>
<label htmlFor="name">Name</label>
<input id="name" defaultValue="Ada" />
</Surface>
);
}
const stage = document.getElementById("stage")!;
const hosts = createCanvasHosts(stage);
const gpu = mountCanvasApp(hosts, <Profile />);
const state = await gpu.enable();
// state.mode is "gpu", or "dom" with state.reason