@objectifthunes/whiteboard
OVERLAYS

Toast

A Zustand toast queue: call toast.success() from anywhere, even outside React. Mount ToastViewport once.


PREVIEW

Queue is empty.

SOURCE
import { ToastViewport, toast } from '@objectifthunes/whiteboard'

// once, near the root
<ToastViewport position="bottom-right" />

// anywhere — including outside React
toast.success('Workspace saved')
toast.error('Upload failed', { description: err.message, duration: 0 })
toast.show('Invoice archived', {
  action: { label: 'Undo', onClick: restore },
})

// or read the queue directly
const count = useToastStore(s => s.toasts.length)
NOTES

There is no provider to wrap your tree in. The queue is a Zustand store, so toast.success() works from a component, a store action, or the catch block of a plain async function with no hook in scope. Mount ToastViewport once, anywhere — it portals to the body, so where it sits in the tree does not matter.

Hovering or focusing a toast pauses its countdown, so one cannot vanish mid-read. Pass duration: 0 for errors that should wait for a dismiss. An action dismisses the toast after running.

The stack keeps the last four and drops the oldest. Toasts sit at --wb-z-toast (4000), above modals on purpose: a failure notice has to survive an open dialog.

This is the transient counterpart to NoteBar. NoteBar is the one persistent banner that stays until the user moves on; a toast is the confirmation that gets out of the way by itself.