Toast

Free

Brief news at the corner on the locked float: a delete that waits while its red rim runs out, the agent asking one question, a run that stopped, money moved, and the everyday note, done, info, warning, error and save, in a stack that fans out.

npx shadcn@latest add https://pixilui.com/r/toast.json

Preview

A delete waits while the red rim runs out; Undo winds it back.
Type

When to use

Use it when

  • A delete or an archive you can still undo: undo holds the action until the rim runs out, and Undo or ⌘Z restores it in place.
  • The agent asking one quick question (agent-asks): the answer that matters is the primary, and the toast turns into the work, then the result.
  • A run that stopped (run-stopped, with ToastSteps) waiting for Retry, or money moved (money-moved) with the Aurora pop and glass light.
  • The everyday set: note, done, info with one action, a warning that lasts, an error that waits, and saving that resolves in the same toast (toast.promise).

Use something else when

  • Something tied to one place on the page: use a notice in that place.
  • Something that affects the whole app (a limit, an outage): use a banner.
  • A decision that cannot wait or must not be missed: use a dialog.

Installation

Terminal
npx shadcn@latest add https://pixilui.com/r/toast.json

Adds toast.tsx with button.tsx and aurora-light.tsx, and installs clsx and tailwind-merge. The URL works in any app with a components.json, with no registry to add first.

Usage

example.tsx
import { Toast } from "@/components/pixilui/toast";

<Toast state={state} />

400 wide in lively and 360 in quiet, never wider than the window less 24px each side; the words take what is left and the line under the title clamps at two lines.

API reference

PropTypeDefault
stateRequiredToastOptions–What the toast says and shows: the same options toast() takes (type, tone, icon or picture, title, sub, undo, actions).
leftnumber | null–With Undo: the ring's share of time left (1 full).
ringOutboolean–The ring is fading out (Undo turned it).
glyphGennumber0Increments when a kept disc's glyph changes.

Also takes every native <div> attribute except title, and a ref.

Keyboard

⌘ ZUndoes the newest toast still holding an action (Ctrl+Z off a Mac), not while typing in a field.
TabReaches the actions and the close, which shows on focus.
Enter SpaceRuns the focused action.

Accessibility

  • The region is a polite live region named Notifications; each toast is role status, so a screen reader hears its title and the line under it.
  • Undo announces its keys (aria-keyshortcuts). A working toast sets aria-busy from its first frame.
  • Pointing at the toasts, a drag, or leaving the tab pauses every timer, so nothing runs out while it is being read; an error never times out.
  • The close has a 36px target around its 24px button. Touch swipes instead.

Motion

  • It rises from the edge out of a blur; the picture springs in 60ms later and its icon plays its move once.
  • Undo: the red rim winds back to full over 420ms, then fades as the disc turns green and the words blur across (200ms).
  • A turn swaps the words through the locked blur (out 140ms ease-in, in 200ms ease-out); a kept disc crosses its glyph in place.
  • The stack fans out while you point at it and glides back on the locked 420ms travel; a swipe flies off at the finger's speed or springs back.
  • Money moved: the locked Aurora pop and glass light, held 1200ms. Reduced motion: everything swaps at once, but the rim still runs: it is the time.
Toast figuresAs the toast lands, the figure replays the moment, then only what changes moves.
BannerIt opens its space, then its line arrives in pieces; an action turns it in place.
NoticeThe space opens first, then the content arrives in pieces; an action turns it in place.

PixilUI Pro opens soon. The first 20 licenses are $99.