Skip to content

feedback · Canvas 2D

FuseToast

An undo message whose time runs out as a fuse burning along its edge, and waits while you read it.

Undo toast whose time runs out as a fuse burning along its edge; it pauses while hovered or focused

  • Canvas 2D
  • Reduced motion: static
  • 3.1 KB gzip
  • Layout shift 0
View the source Spec sheet as Markdown

Install

Install
pnpm dlx shadcn@4.21.1 add @frictionborn/fuse-toast

Playground

The fuse stops while the pointer is over the toast or focus is inside it. Change the length to light a fresh fuse.

Palette
Your code
import { FuseToast } from "@/components/ui/fuse-toast";

<FuseToast open={open} onExpire={commit} onClose={() => setOpen(false)} />

In a full example

The full example loads as you scroll to it.

Accessibility

  • The toast sits in a role=status live region, so its message is announced. The time limit stops while the pointer is over it or focus is inside it (WCAG 2.2.1), and `duration` sets its length. The fuse canvas is aria-hidden.
  • Keyboard: The action is a native button; the fuse stops while focus is inside the toast
  • Touch: The action button
  • WCAG criteria it is built for: 2.2.1, 2.1.1, 4.1.3

Props

PropTypeDefaultWhat it does
openbooleannoneRequired. Shows the toast; a fresh fuse starts each time it opens.
messageReact.ReactNodenoneRequired. What happened.
actionLabelstring"Undo"The action offered while the fuse burns.
onAction() => voidnoneThe action was pressed before the fuse burnt out.
onExpire() => voidnoneThe fuse burnt out: commit the action.
expiredMessageReact.ReactNodenoneShown for 1.2 s after the fuse burns out.
onClose() => voidnoneThe toast should close (after the action, or after the expired message).
durationnumber5000Fuse length in ms (paused while hovered or focused).
palette"fire" | "ice" | "neon" | "mono" | "custom""fire"Colours of the effect (DESIGN.md A8). custom reads --fb-heat-0..4 from the page.
pausedbooleanfalseUniversal pause prop: the effect stops drawing; the control keeps working.
maxTiernumber3Hard ceiling on the capability tier.
noncestringnoneCSP nonce for the component's <style> element.
classNamestring""Extra classes on the root.
styleReact.CSSPropertiesnoneInline styles on the root, merged after the palette variables.
refReact.Ref<HTMLDivElement>noneReceives the root element.

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.

MeasureResult
Size, gzip3.1 KB at load, 0.02 KB loaded later
Layout shift0
Frames when nothing should moveoff screen 0, hidden tab 0, reduced motion 0
axe accessibility scan0 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.

EnvironmentTierResultDateNotes
Chromium Desktop (SwiftShader)3pass2026-10-2116 passed, 0 failed
Chromium Mobile (Pixel 7 emulation)2pass2026-10-2115 passed, 0 failed
Firefox Desktop3pass2026-10-2114 passed, 0 failed
WebKit Desktop3pass2026-10-2115 passed, 0 failed
WebKit Mobile (iPhone 14 emulation)2pass2026-10-2115 passed, 0 failed

On different devices

Reduced motion (static): The toast works and times out the same; the fuse is a plain line with no flame, sparks or canvas.

TierWhat it does
T3 FullEffect on a canvas at DPR <= 2 with the full particle count
T2 StandardEffect on a canvas at DPR <= 1.5 with half the particles
T1 LiteSame as tier 2
T0 StaticThe control alone (server render, reduced motion, Save-Data, no WebGL2): no canvas

Content Security Policy

  • Works without 'unsafe-eval'.
  • Needs no reveal gate.
  • Sets inline style attributes, so allow style-src-attr 'unsafe-inline'.

Goes well with