Toast
Terminal-styled toast notification system. Imperative toast() API callable from anywhere. Supports tone shortcuts (severity), four layout variants, promise handling, and position-aware animations.
Installation
dgadd is not public on npm yet. Until the first release, pack @diffgazer/add from the repository and install that tarball into this app, which is what puts dgadd on pnpm exec.
The hosted registry is not public yet because r.b4r7.dev does not resolve. Use this source checkout or a local registry preview until the endpoint returns 200.
Diffgazer packages are not yet published to npm. Until the first release, pack @diffgazer/ui and @diffgazer/keys from the repository and install those tarballs.
UI components require Tailwind CSS v4. Local copy mode imports src/styles/styles.css; package mode uses @diffgazer/ui CSS once packages are available.
Usage
Examples
All Tones
Layout Variants
With Actions
Positions
Promise
Loading
API Reference
Toaster
toast (function)
Accessibility
Keyboard Navigation
Press Escape to dismiss every visible toast at once. Toast Escape handling is global while toasts are present and runs before lower-priority page overlays unless another handler has already consumed the key. Press the focus hotkey (F8 by default, configurable via the Toaster `hotkey` prop) to move focus into the toast region.
Notes
Imperative API
Call toast(), toast.success(), toast.error(), toast.warning(), toast.info(), or toast.loading() from any code — no provider required. Place a <Toaster /> component in your app layout to render toasts.
Tone vs Variant
`tone` is severity (success/error/warning/info/loading) and drives color and ARIA role. `variant` is the layout shell: `card` (default, full payload), `hud` (single-line pill), `viewfinder` (corner brackets), `countdown` (card + auto-dismiss progress bar).
Promise Support
toast.promise(asyncFn, { loading, success, error }) shows a loading toast that updates to success or error when the promise settles. It returns the input promise and rejects when the input rejects, so callers must handle rejection with await/try-catch or .catch().
Loading Toasts
Loading toasts show a braille spinner and persist when duration is omitted. Use toast.loading() for manual control, or toast.promise() for automatic lifecycle. An explicit positive duration schedules auto-dismissal.
Error Toasts Persist
Toasts with tone='error' persist when duration is omitted and must be closed manually. An explicit positive duration schedules auto-dismissal. The `hud` variant omits the close button and auto-dismisses even for error and loading tones; pass a non-finite duration (Infinity) to opt out.
Actions
Render the `action` slot with the bracketed ghost Button (`<Button variant="ghost" size="sm" bracket>`) so a toast invitation speaks the same [ label ] vocabulary as the rest of the library. A toast with a rendered action and no explicit duration persists until dismissed.
Keyboard
Press Escape to dismiss every visible toast at once, so the key a screen advertises for Escape is at most one extra press away even after an error burst. Toast Escape handling is global when toasts are present, so it runs before lower-priority page overlays that have not already handled the key. Press the focus hotkey (F8 by default, configurable via the Toaster `hotkey` prop) to move focus into the toast region so action and close buttons stay reachable before a timed toast disappears; the hotkey is ignored while an editable element has focus.
Pause Behavior (WCAG 2.2.1)
Auto-dismiss timers pause while the pointer hovers the toaster region, while focus is inside it (so action buttons stay reachable by keyboard), and while the document tab is hidden. Timers resume from the remaining time once interaction ends — users never lose time they could not see or read.
Source
Install via CLI: pnpm exec dgadd add ui/toast. Keyboard hooks are included as standalone copies. For the full experience, use --integration keys.
Highlighted source loads after this disclosure opens. Browse the source repository.