Skip to content

No.29 · Buttons

Dither Button

A button printed in ordered-dither pixels: hover sweeps the fill across cell by cell, and a press knocks the pixels loose before they settle.

The prompt

Copy this text

Automatic copying is unavailable. Copy the selected text using your device’s copy command.

Written for the variant you picked above: Violet

Build a button whose fill is drawn in pixels with an 8×8 Bayer ordered-dither matrix, on a small canvas behind a crisp HTML label. The button is 56px tall, a 1px border in the pixel colour, 4px radius, monospace uppercase label with 0.14em tracking; the canvas fills it at one pixel per 3 CSS px (prop), drawn with fillRect and image-rendering: pixelated. For each pixel at column u (0–1 across the face) the fill level is max(rest, front): rest = 0.34·(1 − u)^1.6 gives a dotted gradient leaning in from the left at rest; front = clamp((p·1.5 − u)·2.4) is a sweep that crosses the face as the hover progress p eases 0 → 1 (lerp 0.11 per frame, also on keyboard focus). A pixel is drawn when its level beats its Bayer threshold, so the face fills in an ordered dissolve rather than a fade, and solidly once the sweep passes. The label colour mixes toward the "ink on fill" colour by p, so it stays readable on the solid face. Pressing (pointer or Enter/Space) gives every pixel within 120px an outward kick from the press point; each pixel then springs home (v = (v − offset·0.16)·0.8), so the grid shatters for a moment and settles. The rAF loop runs only while the sweep or any pixel is still moving. Selected variant — Violet (violet): Pixels in #7c5cff on a violet-black page (#0d0b14); label #e9e4ff turning white on the filled face. This selection takes precedence over references to other themes or options in the general brief. Implement this selected appearance; do not add a variant picker or alternative appearances unless requested. Implementation requirements: Use React and TypeScript. Keep the component self-contained, with uniquely scoped CSS and no animation libraries. Include required imports, styles and font setup in the result. Interaction: Hover or focus to sweep the dithered fill across the face; press to knock the pixels loose. Motion: Hover progress lerp 0.11; press impulse up to 7px with a spring (stiffness 0.16, damping 0.8); press scale 0.98 for 160ms. Accessibility: A real <button> with its text label; the canvas is aria-hidden. Keyboard focus fills the face like hover, and the focus ring uses the pixel colour. Reduced motion jumps the fill and skips the scatter. Responsive behavior: The pixel grid is rebuilt from the button's measured size, so it works at any label length. Touch: On touch the press scatter plays on tap; the hover sweep is skipped. Preserve keyboard access, visible focus and reduced-motion behavior. Keep fictional demo data and simulated service calls in a separate usage example; expose callbacks for real actions and recover from rejected requests. Keep usage-example links inside the demo: use local buttons or prevent navigation. Demonstration links must not navigate to Vitrine routes or open other pages; preserve real URL support in the reusable component itself. Verify the result at narrow and wide viewport sizes, with keyboard input and reduced motion enabled.

Notes

Interaction
Hover or focus to sweep the dithered fill across the face; press to knock the pixels loose.
Motion
Hover progress lerp 0.11; press impulse up to 7px with a spring (stiffness 0.16, damping 0.8); press scale 0.98 for 160ms.
Accessibility
A real <button> with its text label; the canvas is aria-hidden. Keyboard focus fills the face like hover, and the focus ring uses the pixel colour. Reduced motion jumps the fill and skips the scatter.
Responsive
The pixel grid is rebuilt from the button's measured size, so it works at any label length.
On touch
On touch the press scatter plays on tap; the hover sweep is skipped.