A toast viewport to mount once, anywhere in the app; `showToast()` from anywhere then renders a dismissible, auto-expiring Radix toast in it.

pnpm add @behivetech/atoms.toast

This is the snapshot of v0.5.3, the current version, as recorded on 2026-11-10. The live page runs its examples →

A toast viewport to mount once, anywhere in the app; showToast() from anywhere then renders a dismissible, auto-expiring Radix toast in it.

Usage

1import { Toast } from "@behivetech/atoms.toast";
2
3<Toast>Content</Toast>;

Properties

Toast props

PropTypeDefaultDescription
durationnumber5000How long a toast stays visible before auto-dismissing, in ms. Defaults to 5000.

Functions

showToast function

Queues a toast on any mounted `Toast` component. Dispatches a plain `window` event under the hood, so it's callable from anywhere with no React context required — including directly from the browser console, e.g. `showToast({ title: "Saved", variant: "success" })`.

showToast(message: Omit<ToastMessage, "id">): string
ParameterTypeDefaultDescription
messageOmit<ToastMessage, "id">——

Returns string — the toast's id, which `dismissToast` takes to remove it early

dismissToast function

Removes a toast before it expires, for a message that stopped being true (an error toast after the retry succeeded). Does nothing for an id that has already expired.

dismissToast(id: string): void
ParameterTypeDefaultDescription
idstring—The id `showToast` returned

Returns void