Studio Tools · open-source library · MIT
Hairline
Thirty-three isometric line figures that answer the pointer. For React and for anything with a DOM.
The figures
Move the pointer over a figure, or drag a finger across it. Each one answers in its own way, and writes a read-out to its corner. shown.
Use it
Anything with a DOM
A figure draws into the element you give it, at that element’s width and a 5:4 aspect ratio. update changes options on the running figure; destroy removes what the figure added. That is the shape of a Svelte action, so use:terrain works as it is.
React
Every component takes the same options and every <div> attribute, and forwards its ref. On the server it renders an empty 5:4 box, so nothing shifts when it draws.
Five options, the same on every figure
| Option | Type | Default | |
|---|---|---|---|
intensity | number | 0.5 | How strongly the figure answers the pointer, from 0 (subtle) to 1 (strong). |
theme | "auto" | "light" | "dark" | "auto" | Auto follows the page: an ancestor with class dark or data-theme="dark", then the page’s color-scheme. |
label | string | English | The accessible name. |
onRead | (text) => void | The figure’s caption each time it changes, such as "03" or "gap 28.0". The corner read-outs on this page come from it. | |
play | boolean | false | Walks the figure through its answer on its own, until the pointer or focus arrives. The tours on this page are this option. |
Theme with six custom properties
The palette buttons above set these on the page. The figure’s styles have no specificity, so any rule of yours wins. Plates are filled, not transparent, so --hairline-plate must match the background behind the figure.
.figures {
--hairline-plate: #101014; /* the fill of every plate */
--hairline-hi: #fafafa; /* what is lit */
--hairline-edge: #a1a1aa; /* silhouettes */
--hairline-mid: #52525b; /* every other stroke */
--hairline-lo: #27272a; /* what recedes */
--hairline-stroke: 0.9; /* stroke width, in CSS px at any size */
}
How it behaves
- One frame loop. Every figure on a page shares one
requestAnimationFrameloop. A figure off screen or at rest does no work, and the loop stops when nothing moves. This page mounts all thirty-three for that reason. - Lines, not pixels. Each figure is an SVG of filled plates drawn back to front, with non-scaling strokes, so the hairline stays one width at any size.
- Accessibility. A figure is an image with a description. Riffle is a focusable group: the arrow keys walk its cards and a live region reads them out.
- Reduced motion. With
prefers-reduced-motion, the figures that play on their own hold still, and every figure still answers the pointer. - Shadow DOM. A figure mounted inside a shadow root styles itself there.
Make your own
The repository also ships two skills for coding agents. /hairline-create a sales funnel offers concepts, draws the one you pick on the same engine, checks it against Hairline’s ten rules, and hands over one HTML file with no dependencies. /hairline-adopt icons/deploy.svg rebuilds an SVG icon or logo as a figure and proposes what the pointer does to it. See what both skills drew and how Hairline was made.
The figures on this page are mounted by a JavaScript module. If you can read this line for more than a moment, the module did not run in this browser.