Skip to content

WebGPU demo: a live data grid in the browser

A WebGPU demo, 150 simulated quotes in a live data grid: a still of the example running

GPUI in WebAssembly, loaded only when you ask.

Open full page

The demo draws with WebGPU where the browser has an adapter for it, and with WebGL 2 where it has not.

Most WebGPU demos are 3D scenes. This one is an application’s interface: a data grid of 150 simulated quotes grouped by sector, where each cell that changes flashes green or red and the sector rows keep live averages. None of it is HTML. The table, its text and its scrollbars are drawn on one canvas, at about 300 updates a second.

  • The interface is GPUI, the UI framework of the Zed editor. It lays the window out and paints it on the GPU as quads, glyphs and paths.
  • The table is gpui-kit-grid, a data grid for GPUI written in Rust. One element paints the visible cells; sorting and grouping run in the background, between frames in a browser.
  • The page runs WebAssembly. The same Rust code that opens a desktop window is compiled for wasm32-unknown-unknown: about 7 MB to download, loaded when you press the button.
  • WebGPU first, WebGL 2 otherwise. The demo asks the browser for a WebGPU adapter and falls back to WebGL 2 without one. The same demo on WebGL 2 looks the same.

The same grid under other loads, each on a page of its own:

Examples has all eight that run in the browser, Web how they are built and their frame times, and Performance the measurements on the desktop.

Two lines show this demo on any page, and Play recolours it first. Embedding has the element’s attributes.

<script type="module" src="https://gkg.giglabo.com/embed/v1/live-grid.js"></script>
<live-grid app="quotes" autoload></live-grid>
Open in MDN Playground

Apache-2.0, built on gpui-kit. Repository Sponsor More from GigLabo Privacy Licenses