cta · Canvas 2D
FlintButton
A button that strikes like flint: a steel rakes the stone and throws sparks, and enough heat makes it catch.
Button that strikes like flint: a steel rakes the stone and throws sparks; heat builds until it catches
- Canvas 2D
- Reduced motion: static
- 3.13 KB gzip
- Layout shift 0
Install
pnpm dlx shadcn@4.21.1 add @frictionborn/flint-button
Playground
Click it, or rub across the stone fast: enough heat makes it catch.
import { FlintButton } from "@/components/ui/flint-button";
<FlintButton>
Strike
</FlintButton>In a full example
The full example loads as you scroll to it.
Accessibility
- A native <button> with its text label (which becomes litLabel while it burns). The optional heat status under it is aria-live=polite. The spark canvas and the steel are aria-hidden. Sparks last under 3 s per strike.
- Keyboard: A native <button>: Enter and Space strike, focus ring visible
- Touch: Tap strikes
- WCAG criteria it is built for: 2.1.1, 2.4.7, 4.1.2, 4.1.3
Props
| Prop | Type | Default | What it does |
|---|---|---|---|
children | React.ReactNode | none | Required. The button's label while cold. |
litLabel | React.ReactNode | "Lit" | The label while the stone burns. |
statusText | { cold: string; warm: string; hot: string; burning: string } | null | "{ cold: \"Cold stone\", warm: \"Warm\", hot: \"Hot\", burning: \"Burning\" }" | Visible heat status under the button (aria-live polite); null hides it. |
onClick | React.MouseEventHandler<HTMLButtonElement> | none | Your action; runs on every strike. |
palette | "fire" | "ice" | "neon" | "mono" | "custom" | "fire" | Colours of the effect (DESIGN.md A8). custom reads --fb-heat-0..4 from the page. |
paused | boolean | false | Universal pause prop: the effect stops drawing; the control keeps working. |
maxTier | number | 3 | Hard ceiling on the capability tier. |
nonce | string | none | CSP nonce for the component's <style> element. |
className | string | "" | Extra classes on the root. |
style | React.CSSProperties | none | Inline styles on the root, merged after the palette variables. |
ref | React.Ref<HTMLButtonElement> | none | Receives the <button>; className, style and the rest of the props go on the button too. |
Measured on the bench
Measured by the automated bench at commit 801163e on 2026-10-21. These numbers are written by the bench, never by hand.
| Measure | Result |
|---|---|
| Size, gzip | 3.13 KB at load, 0.02 KB loaded later |
| Layout shift | 0 |
| Frames when nothing should move | off screen 0, hidden tab 0, reduced motion 0 |
| axe accessibility scan | 0 serious, 0 critical |
Browsers it ran in
Automated Playwright runs, some with device emulation. Results from physical phones and tablets are still pending, so none are listed.
| Environment | Tier | Result | Date | Notes |
|---|---|---|---|---|
| Chromium Desktop (SwiftShader) | 3 | pass | 2026-10-21 | 16 passed, 0 failed |
| Chromium Mobile (Pixel 7 emulation) | 2 | pass | 2026-10-21 | 15 passed, 0 failed |
| Firefox Desktop | 3 | pass | 2026-10-21 | 14 passed, 0 failed |
| WebKit Desktop | 3 | pass | 2026-10-21 | 15 passed, 0 failed |
| WebKit Mobile (iPhone 14 emulation) | 2 | pass | 2026-10-21 | 15 passed, 0 failed |
On different devices
Reduced motion (static): A plain stone button: no steel, no sparks, no glow, no canvas. Clicks work as usual.
| Tier | What it does |
|---|---|
| T3 Full | Effect on a canvas at DPR <= 2 with the full particle count |
| T2 Standard | Effect on a canvas at DPR <= 1.5 with half the particles |
| T1 Lite | Same as tier 2 |
| T0 Static | The control alone (server render, reduced motion, Save-Data, no WebGL2): no canvas |
Content Security Policy
- Works without
'unsafe-eval'. - Uses the reveal gate (
[data-motion="ok"]): render<MotionReadyScript />in<head>(with yournonce), or callinitMotionReady()in Vite. - Sets inline
styleattributes, so allowstyle-src-attr 'unsafe-inline'.