Documentation

  • 311 sections
  • Solid
  • Tailwind or StyleX

Quick start

The kit is a folder, not a package. Copy dither-kit/ from the GitHub repo (opens in a new tab), install four small runtime deps and alias it. You already have Solid, and Tailwind if you use it.

  1. Copy the kit folder straight from the repo

    degit grabs just the folder

    npx degit drvova/dither-ui/packages/dither-kit/src src/dither-kit
  2. Install the runtime deps

    you already have Solid, and Tailwind if you use it

    npm i d3-scale d3-shape clsx tailwind-merge
  3. Alias @dither-kit so imports stay clean

    // vite.config.ts
    resolve: { alias: { "@dither-kit": "/src/dither-kit/solid" } }
    
    // tsconfig.json, under compilerOptions
    "paths": { "@dither-kit": ["./src/dither-kit/solid"] }
  4. Use it

    import { AreaChart, Area, DitherButton } from "@dither-kit"

Without Tailwind

The kit brings its own stylesheet, in cascade layers so your styles win. Pick your system in the header and every snippet here, every Studio export and the agent's code.get come out as a scoped stylesheet, CSS Modules or StyleX.

<!-- No Tailwind? One plain stylesheet: the tokens, a base scoped to
     .dither-kit and every class the components use. -->
<link rel="stylesheet" href="https://dither-ui.com/kit/dither-kit.css">

<div class="dither-kit">
  <DitherButton class="cta">Ship</DitherButton>
</div>

The tokens are plain custom properties, so theme from CSS, JS or any vars contract:

import { applyTheme, themeCss } from "@dither-kit"

applyTheme({ accent: "#3f8ff3", radius: "4px" })  // on <html>, returns the undo
themeCss({ background: "#000" }, ".dark")          // a rule for your stylesheet

Prefer to read the source first? Every component lives under dither-kit/ (opens in a new tab). No build step, no black box.

Engine

The parts under every surface, each named once: what it does in one line, and a figure read from the kit's own source.

Matrix
Each cell compares its tone with one rank of a 4×4 threshold matrix and lights when the tone passes it, so a flat fill becomes a pattern of lit and unlit cells. Print screens
16 ranks, 17 tones
Screens
The matrix is Bayer's unless a DitherScreen around a surface picks a printer's line, diagonal, dot or cross; a fill that carries a label keeps Bayer, so its letters hold. Print screens
5 screens
Seeds
One integer seeds the matrix's jitter, the texture, the bloom and the easing, so the same seed draws the same surface every time. Seeds
1 integer
Palette
One table resolves each hue to the fill, line and star colours every surface paints with, and the theme's swatches mirror it. Palette
7 hues
Clock
One clock drives every animation; held at a moment, every surface paints that moment, and the same moment gives the same bytes. Stage
0 frames while held
Wipe
Reveals and page transitions are ordered-dither masks: a cell shows once the sweep passes its rank in an 8×8 matrix, so a wipe has a dithered front, never a soft edge. Dither reveal
64 ranks
World
Model files parse in the page and rasterize on the CPU byte for byte, or on WebGL for big meshes, into the same dither pass. World (3D)
8 formats
Shader
GLSL compiles offscreen at the cell resolution and its pixels are read back and dithered; iTime is the kit's clock, and other surfaces bind as its inputs. Shader (GLSL)
4 inputs

Verification

The kit's claims, measured with its own engine in the browser reading this page: what each one claims, how it is measured and against what, then the reading. CI takes the same readings on every push, and each claim links the test that holds it.

Measured in your browser when this section comes into view.

Same seed, same moment, same bytes
The poster is printed twice at seed 5 and 2.4 s and every byte compared; printed again at 3.4 s, the control must differ. Its test: Same seed, same moment, same bytes (opens in a new tab)
not yet measured
against 0 bytes differ
The same bytes in every engine
The same print is hashed through the kit's FNV-1a and set beside the hash CI recorded running the kit in Node. Its test: The same bytes in every engine (opens in a new tab)
not yet measured
against hash c8364f4f
Every screen prints 17 tones
Each screen's 4×4 thresholds are set against 17 even tone steps by the rule every surface prints with, a cell lighting when the tone passes its threshold, and the lit cells counted. Its test: Every screen prints 17 tones (opens in a new tab)
not yet measured
against step k lights k cells
The 3D engine repeats itself byte for byte
A box read from a VRML file is rasterized twice on the CPU at one view and every byte compared; turned 15°, the control must differ. Its test: The 3D engine repeats itself byte for byte (opens in a new tab)
not yet measured
against 0 bytes differ
A scene scales exactly with its box
A track of container units and percentages is sampled at 0.7 s and resolved in a 320 by 180 box, then in one twice that size. Its test: A scene scales exactly with its box (opens in a new tab)
not yet measured
against every length doubles
A wipe shows one more cell per step
The dissolve's mask is drawn at each of the 64 steps of its 8×8 matrix and its shown cells compared step to step. Its test: A wipe shows one more cell per step (opens in a new tab)
not yet measured
against one more each step
8 model formats read in the page
A triangle written in each format (a Gaussian in the capture's) is parsed by the kit's own readers, here, with nothing fetched. Its test: 8 model formats read in the page (opens in a new tab)
not yet measured
against a triangle or a Gaussian from each
The landing's inks hold their contrast as printed
Bone, muted bone and the ember are printed through the Bayer matrix on the obsidian at full and half tone, and each patch is measured from its pixels in linear light. Its test: The landing's inks hold their contrast as printed (opens in a new tab)
not yet measured
against 4.5:1 full, 3:1 at half

Video player

A native video under dither chrome: play, a dithered scrubber that really seeks, a volume slider, playback speed, mute, fullscreen, and player keyboard (Space, arrows, M, F). Without a source it shows an honest empty face instead of a broken box.

src
Typestring: no src renders an honest empty face Defaultundefined
poster
Typestring Defaultundefined
label
Typestring: accessible name Default"Video"
color
TypePixelColor: scrubber and volume hue Default"blue"
keyboard
TypeSpace/K play, ←→ seek 5s, ↑↓ volume, M mute, F fullscreen Defaultnone

Bracket

A knockout bracket: winners carry the accent, losers strike through, connector rails bridge the rounds. This one is interactive: pick every winner and the final fills itself.

rounds
Type{ a, b, winner? }[][]: columns left to right Defaultrequired
color
TypePixelColor: winner accent Default"green"
interactive
Typeboolean: click a side to pick Defaultfalse
onPick
Type(round, match, side): consumer advances the data Defaultnone

Schedule

A day timeline: events sit proportionally on the hour rail, each with its swatch rail, and the red now line slides as the day moves. Drag the hour to move time.

events
Type{ start, end, label, color? }[]: fractional hours Defaultrequired
from / to
Typenumber: day window Default8 / 18
now
Typenumber: draws the now line; omit to hide Defaultundefined

World (3D)

A 3D model viewer in the house raster: VRML, X3D, glTF / GLB, OBJ with its MTL, STL, PLY, OFF and Gaussian splats, by URL or inline, drawn on the CPU or through WebGL for big meshes. Files bring their own materials, lights and animations, played on the kit clock; any kit surface can skin the model (the aurora below), and any model comes apart along its seams and builds itself back. Drag to orbit.

A model's own animation and a build share one clock. This rocket is a VRML file: its flame flickers by its own TimeSensor, it climbs off the pad, and at the top the file swells a fireball while the page blows its pieces apart with scatter.

Gaussian splats print too: a capture is a cloud of soft ellipsoids, each laid on the cells as its footprint, near to far until a cell is opaque, and its colour and light go through the same dither. This one is our mascot, grown from its cell table into a body of splats with three electrons ringing it. Give it a .splat file or the .ply a trained capture writes.

src
Typestring: URL of .wrl (VRML97 / 1.0 / X3D classic), .x3d, .gltf / .glb (+ .bin), .obj (+ .mtl), .stl, .ply, .off, or a Gaussian capture (.splat, a trained .ply) Defaultundefined
source
Typestring: inline model text; wins over src Defaultundefined
format
Type"auto" | "vrml" | "x3d" | "gltf" | "obj" | "stl" | "ply" | "off" Default"auto"
up
Type"auto" | "y" | "z" | "-y": the file's up axis (STL defaults to z, a capture to -y) Default"auto"
engine
Type"auto" | "cpu" | "gpu": the CPU engine is byte-exact everywhere, the GPU (WebGL) engine rasterizes big meshes; auto picks the GPU above ~40k triangles Default"auto"
color
TypePixelColor: the dither fill Default"blue"
colors
TypePixelColor[]: a toon ramp, dark to light; lighting picks the band, the Bayer cell dithers between bands Defaultundefined
dither
Typenumber: ramp mode, 0 smooth → 1 banded Default1
material
Typeboolean: the file's own colours (materials, face and vertex colours) Defaultfalse
wire
Typeboolean: polygon outlines, hidden lines removed Defaultfalse
shader
Typestring: a GLSL material over the finished target. mainMaterial(out vec4, in vec2) reads dk_shade, dk_depth, dk_covered and dk_color per cell and returns rgb + the shade the Bayer cell thresholds (WebGL) Defaultundefined
channels
TypeChannelInput[]: kit surfaces (pulled at the same clock time), canvases, images or videos; the first is the model's skin through its texture coordinates, a shader reads them as iChannel0..3 at dk_uv(p) Defaultundefined
grain / grainScale
Typenumber: fbm grain over the model's own space, and its frequency Default0 / 4
bloom
Type"off" | "low" | "high" | "aura" | config | seed: the glow layer Default"off"
animate / time
Typeboolean / number: play the file's animations (VRML ROUTEs, glTF) on the clock, or pin a moment Defaulttrue / undefined
seed
Typenumber: dither matrix, grain + the sample world Defaultundefined
cell
Typenumber: backing cell in CSS px Default3
autoRotate
Typenumber: degrees per second, 0 holds Default12
yaw / pitch / zoom
Typenumber: the pose; unset, the file's Viewpoint decides Default30 / 20 / 1
fov
Typenumber: vertical field of view, degrees Default40
shade
Typenumber: alpha of unlit cells inside the silhouette Default0.18
fog
Typenumber: depth fade of the lighting Default0.3
interactive
Typeboolean: drag or arrow keys orbit Defaulttrue
build
Typenumber: the model as a build, 0-1; its separate pieces rise from a dotted wire cage bottom to top, each flying in hot until it lands Default1
scatter
Typenumber: the pieces blown apart and turned, 0 together → 1 apart Default0
heat
TypePixelColor: the colour a piece glows in while it flies in Default"orange"
nudge
Typeboolean: pieces under the pointer lean away from it, then settle Defaultfalse
label
Typestring: accessible name Default"3D model"
frameRate
Typenumber: stop-motion cadence in fps (0 = smooth) Default0
paused / renderMode
Typeboolean / "live" | "static" Defaultfalse / "live"

Shader (GLSL)

A fragment shader in the house raster: Shadertoy-style mainImage or a raw main, by URL or inline, run on the GPU at the cell resolution and dithered on the way back, one bit per channel or one tint. iTime is the kit clock, so it seeks and renders to video, and any kit surface can feed it as iChannel0..3. Below, an aurora through a CRT.

src
Typestring: URL of a .frag / .glsl file Defaultundefined
source
Typestring: inline GLSL (Shadertoy mainImage or a raw main); wins over src Defaultundefined
channels
Type(surface | component | canvas | image | video)[]: bound as iChannel0..3; a kit surface is pulled at the same clock time, so the graph seeks and renders as one Defaultundefined
uniforms
TypeiResolution, iTime, iTimeDelta, iFrame, iMouse, iDate, iColor, iSeed, iChannel0..3 and iChannelResolution, plus time/resolution/mouse and u_time/u_resolution/u_mouse; dk_bayer4(fragCoord) is the kit's Bayer threshold Defaultnone
color
TypePixelColor: the mono tint and iColor Default"blue"
colors
TypePixelColor[]: a palette ramp; luminance picks the band, the Bayer cell dithers between bands Defaultundefined
mono
Typeboolean: 1-bit luminance in color instead of the shader's colours Defaultfalse
dither
Typenumber: 0 smooth → 1 fully quantized Default1
levels
Typenumber: colour levels per channel (2 = eight colours) Default2
shade
Typenumber: in mono, the alpha floor of unlit cells Default0
speed
Typenumber: multiplies iTime Default1
seed
Typenumber: dither matrix + the sample shader Defaultundefined
cell
Typenumber: backing cell in CSS px; the shader runs at this resolution Default3
interactive
Typeboolean: the pointer feeds iMouse Defaulttrue
label
Typestring: accessible name Default"Shader"
frameRate
Typenumber: stop-motion cadence in fps (0 = smooth) Default0
paused / renderMode
Typeboolean / "live" | "static" Defaultfalse / "live"