Customize
This page covers the figure plate, the FS.figure spec, runnable samples, prose bindings, React assets and writing styles. Each sample uses the code shown with it.
The plate
A plate is plain HTML: a head with the claim, a stage with the drawing, an optional toolbar and caption. Controls are attributes, so they need no glue code.
<figure class="fs-plate">
<header class="fs-head"><h3 class="fs-title">The claim, as a sentence</h3><span class="fs-status">Illustration</span></header>
<div class="fs-stage"><canvas id="my-fig"></canvas></div>
<div class="fs-toolbar">
<span class="fs-position" data-fs-out="my-fig:t"></span>
<div class="fs-controls"><div data-fs-seek="my-fig"></div><button data-fs="my-fig play"></button></div>
</div>
<p class="fs-caption">What is measured or made up, and how to play with it.</p>
</figure>
Load themes/base.css, one token layer such as themes/default.css, and assets/runtime/fs-runtime.js. The standalone starter assets/plate-template.html has all three inlined.
The spec
| Option | What it does |
|---|---|
height(w) | The drawing's height in CSS px for a width. Switch layouts at narrow widths instead of shrinking text. |
duration, loop | A timeline of fixed length that plays once to its payoff, or loops. Leave both out for an endless process. |
params | Named values that ease toward their targets. Numbers become sliders, booleans switches, options segmented buttons. They go in the settings popover unless placement: "inline"; hidden: true keeps one out. |
handles | Parts of the drawing the reader drags: get, set, bounds, optional release and radius. Keyboard and touch included; past the bounds they rubber-band and spring back. |
steps | Discrete states with captions. Draw the change from f.from to f.step with f.stepT going 0 to 1. |
chapters | Stops on a timeline, for the arrow keys, chapter buttons and the scrubber's marks. |
timeAxis(f) | Maps time onto the drawing, so the figure itself scrubs: hover to preview, drag, click to jump, flick to coast. |
tips, tipAt | Short explanations for drawn parts, after a hover delay and at once on keyboard focus. |
reserve | The widest text each output can show, so changing numbers never push the layout around. |
expand | "fit" (default) scales the plate up to 84% of the viewport with the same layout. "fill" lays it out again at the new width. false removes the button. |
autoplay, keyframe, settle | Whether it starts when scrolled into view, and what a reader with reduced motion sees: a timeline's keyframe, or a process run settle seconds ahead. |
formatTime, stepDuration | How time reads in outputs and the scrubber; how long a step change takes (0.48 s). |
init, update, render | Hooks, plus resize, onParam and onStep. render(f, ctx) draws only from state: f.t, f.step, f.v (eased params), f.hover, f.drag, f.w, f.h and the theme in f.C. |
Samples that run
params
The one control that is the interaction sits in the toolbar. Everything else lives behind the settings icon in the plate's corner.
A wave with one knob outside and two inside
handles
If a value has a place in the drawing, the reader drags that place. Drag past the dashed box and let go.
A point that rubber-bands at its bounds
steps
Each step changes one thing. Captions stack in one box, so it never changes height.
Three steps, one change each
chapters and timeAxis
A timeline is a function of one clock. With timeAxis, the drawing is the scrubber; the toolbar scrubber, the arrow buttons and the keys all glide the same clock.
A six-second clock with two stops
tips and tipAt
Hover a bar and wait half a second. Once one tip is open, the next opens at once. In HTML or SVG, data-fs-tip does the same with no code.
Parts that explain themselves
Illustrationreserve
Drag the slider from 0 to the end. The words after the number stay where they are, because the number keeps the width of its widest value.
A number that never moves its neighbors
expand: fit and fill
Open both from their corners. Fit, the default, scales the plate up and keeps its layout, so proportions never change; the canvas renders at the larger size. Fill lays the figure out again at the wider width, which suits drawings that reflow, like a Mermaid diagram or this grid.
Fit
Fill
Events
Figures report what happens to them. This listens to three figures above; use any of them and watch this line:
Waiting for an event…
The events are play, pause, end, seek, scrub, step, param, reset, hover, dragstart, drag, dragend and expand. on() returns a function that removes the listener.
The FS API
Anything a reader can do, code can do, through the same path. Each button below runs the line on it.
Click a line to run it.
| Call | What it does |
|---|---|
play(), pause(), toggle() | Run or hold the clock. A finished timeline replays from the start. |
seek(t, { animate }) | Jump to a time, or glide there on a spring that keeps its speed if you retarget. |
chapter(±1) | Glide to the next or previous stop. |
goto(n), next(), prev() | Move between steps. |
set(name, value) | Change a param; pass an object to set several, and { instant: true } to skip the ease. |
state(), apply(state) | Read or restore { t, step, params, playing }: presets, shared links, tests. |
out(name, text) | Write a computed value to every data-fs-out="id:name", in the figure or the prose. |
hover(key) | Light a part, the same way a linked word does. |
expand(), collapse(), openSettings() | Open the plate full screen or its settings. |
redraw(), dispose() | Ask for a frame; release observers when a page or component goes away. |
FS.get, FS.list | Find figures by id. |
FS.setTheme, FS.setMode | Switch the theme for the page, or pass an element to theme just that one. |
FS.k, FS.ease, FS.rng | The drawing kit (text, labels with halos, hatching, brackets, playheads), easings, a seeded random generator. Also FS.window, FS.spring, FS.rubber, FS.slider. |
Prose that drives a figure
Numbers in a sentence can be the control, and words can point at parts. This word lights the plateau. At a smoothing of , the plateau shows up tall instead of , and peaks steps late. Drag the number, or focus it and use the arrow keys.
Smoothing hides the plateau
Simulated, seededMade-up training loss with a short stall in the middle. Hover for values; the raw series can be turned off in settings.
At a smoothing of <span data-fs-scrub="demo-curve:smooth"></span>,
the <span data-fs-ref="demo-curve:plateau">plateau</span> shows up
<span data-fs-out="demo-curve:bump"></span> tall.
The other bindings: data-fs="id play|next|prev|reset|chapter-next|chapter-prev" on buttons, data-fs-param="id:name" for a slider, data-fs-seek="id" for a scrubber, data-fs-dots="id" for step dots and data-fs-tip for an explanation on any element.
React
assets/react/ wraps the same runtime, so figures behave the same in a Next.js site. The hook mounts a figure and disposes it on unmount; never set React state per frame.
| File | What |
|---|---|
useFigure.ts | useFigure(id, spec) loads the runtime in the browser, mounts the figure and returns its controller. |
FigurePlate.tsx | The plate markup with the data-fs* bindings wired. |
FlowDiagram.tsx | A stepped architecture diagram with packets, two layouts. |
ExplorableLine.tsx | A nivo line chart with one parameter and direct labels. |
FocusField.tsx | A react-three-fiber particle field with a depth-of-field focus pull. |
nivo-theme.ts | A nivo theme on the --fs-* tokens, plus reduced-motion and token hooks. |
React, not run on this page
"use client";
import { useFigure } from "./useFigure";
import { FigurePlate } from "./FigurePlate";
export function Wave() {
useFigure("wave", {
height: () => 150,
params: { amp: { value: 0.6, min: 0.1, max: 1, label: "Height", placement: "inline" } },
render(f, c) { /* the same render as the params sample */ },
});
return (
<FigurePlate id="wave" title="A wave you can tune" status="Illustration" params={[{ name: "amp", label: "Height" }]}>
<canvas id="wave" />
</FigurePlate>
);
}
Setup, pinned versions and lazy loading are in assets/react/README.md.
Writing styles
Every label, caption and tip follows one writing style per page. Practical is the default: plain words, a stance first, a moment the reader has lived. Academic is for papers: formal, numbered, with units, n and uncertainty. Ask for academic and the agent switches.
| Practical | Academic |
|---|---|
| Independent actions run at the same time | Independent actions execute concurrently |
| 2.3× longer | 2.28× longer than the concurrent schedule (sum of measured durations) |
| Hover a block to see what it is | Hover to inspect each component's definition. |
Styles are one file each in references/writing/, with the same sections, so adding your own is copying one and filling it in.