Every prop of the DotMatrix component and its look object, with types and defaults, and every export of the engine files.
Reference · 3 min read
DotMatrix is the one component of the engine. It renders an <output> element.
import { DotMatrix } from "@/components/ui/dot-matrix/dot-matrix";Props
| Prop | Type | Default | What it does |
|---|---|---|---|
pattern | pattern name or ScenePattern | "orbit" | What the dots draw. See Built-in patterns and Write a pattern |
lattice | layout name or { cols, rows, mask?, hex? } | "square" | Where the dots sit. See Layouts and dots |
size | number | 20 | The height in CSS pixels. The width follows the lattice. Values under 8 use the default |
color | string | the text color | The dot color: any CSS color, such as "#2BD4E0" or "var(--chart-2)" |
look | DotMatrixLook | none | Dot shape, glow, density, speed, palette and morph. A decoded preset fits as it is |
value | number, 0 to 1 | 0 | The input of a pattern that reads one, such as progress |
state | "running" or "paused" | "running" | paused holds the current frame |
active | boolean | true | false morphs every dot dark, for an exit |
enter | boolean | false | Morphs in from dark when the loader first comes on screen |
renderer | DotMatrixRenderer | canvas | How the dots are drawn. See Dots engine |
messages | { loading, success, failure } | English | What a screen reader hears for each kind of pattern |
Every other attribute of <output> passes to the root: className, id, aria-label, aria-hidden, data-* and event handlers. A className with a text color, such as text-amber-500, sets the dot color when you do not pass color.
A wrong value never breaks the loader. An unknown pattern name shows orbit, an unknown lattice shows square, and a number out of range is held to its range or uses its default.
The look object
look holds the parts of a loader's style that a preset can save. Every key is optional.
| Key | Type | Default | What it does |
|---|---|---|---|
pattern | pattern name or ScenePattern | none | Used when the pattern prop is not set |
lattice | layout name or spec | none | Used when the lattice prop is not set |
dot | dot shape name | "round" | How each dot is drawn: one of 9 shapes |
glow | number, 0 to 1 | 1 | The halo of a lit dot. Light pages show a third of it |
floor | number, 0 to 1 | 1 | The dots that are off. 0 hides them |
speed | number | 1 | Loop speed. 2 is twice as fast |
colors | string[], 2 to 8 | none | A palette for a pattern with a tint channel. The first color is the dot color |
morph | morph name or "none" | "wave" | How a change travels over the dots |
grid | number | from size | A fixed number of dots along the height |
The props win over look. So pattern wins over look.pattern, and color wins over the first color of look.colors.
Names
| List | Values |
|---|---|
| Layouts | square, circle, rounded, ring, capsule, bar, hex |
| Masks of your own grid | rect, circle, rounded, capsule, ring |
| Dot shapes | round, square, pixel, triangle, diamond, star, plus, ring, dash |
| Morphs | wave, implode, sweep, dissolve, flow, fly, and none |
| Patterns | 34 names. See Built-in patterns |
Exports
Each file installs into components/ui/<item>/. Import from the file that owns the name.
| File | Exports |
|---|---|
dot-matrix/dot-matrix | DotMatrix |
dot-matrix/dot-matrix-patterns | DOT_MATRIX_PATTERNS (every built-in scene, by name), DOT_MATRIX_PATTERN_NAMES, patternOf, type DotMatrixPatternName |
dot-matrix/dot-matrix-scene | types ScenePattern, SceneValue, SceneForm, SceneField; VALUE_SPEC, FORM_SPEC, FIELD_SPEC, SCENE_REFS, SCENE_FONTS |
dot-matrix/dot-matrix-preset | parsePreset, decodePreset, encodePreset, PRESET_KIND, PRESET_VERSION; types DotMatrixPreset, DotMatrixLook, PresetResult |
dot-matrix/dot-matrix-lattice | DOT_MATRIX_LATTICES; types DotMatrixLatticeName, DotMatrixLatticeSpec, DotMatrixMask |
dot-matrix/dot-matrix-dots | DOT_MATRIX_DOTS, type DotMatrixDot |
dot-matrix/dot-matrix-morph | DOT_MATRIX_MORPHS, type DotMatrixMorph |
dot-matrix/dot-matrix-ease | EASE_NAMES, type EaseName |
dot-matrix/dot-matrix-messages | dotMatrixMessages, type DotMatrixMessages |
dot-matrix/dot-matrix-canvas | canvasRenderer |
dot-matrix/dot-matrix-renderer | types DotMatrixRenderer, DotMatrixScene, DotMatrixPlayer |
dot-matrix-dom/dot-matrix-dom | domRenderer |
dot-matrix-svg/dot-matrix-svg | svgRenderer |
dot-matrix-webgl/dot-matrix-webgl | webglRenderer |
Use the lists to build a picker:
import { DOT_MATRIX_PATTERN_NAMES } from "@/components/ui/dot-matrix/dot-matrix-patterns";
<select>
{DOT_MATRIX_PATTERN_NAMES.map((name) => (
<option key={name}>{name}</option>
))}
</select>;The full grammar of a scene, node by node, is in the Scene reference.