Oddmash UI
All components

Toast Provider

Manage independent notifications, expiry and dismissal.

Usage

Mount ToastProvider once for a product surface, then call showToast from useToast after a real result. A full visible stack queues new notifications until space is available.

Accessibility

Show confirmations politely and errors as alerts, without moving focus on arrival. Expiry pauses during hover or focus. Dismissal restores focus to a remaining notification or the original control.

PropertyTypeDefault
maxVisiblenumber4
dismissLabelstringDismiss notification
showToast(options)ToastNotification → stringRequired title
dismissToast(id)string → voidNone
duration (notification)number | null3000; important states persist
const Controls = () => {
  const { showToast } = useToast();
  return (
    <div>
      <Button onClick={() => showToast({ title: 'Project saved', description: 'Your changes are ready.', tone: 'success' })}>
        Show saved notification
      </Button>
      <Button variant="secondary" onClick={() => showToast({ title: 'Save failed', description: 'Your changes could not be synchronized. Check your network connection and retry when you are ready.', tone: 'error' })}>
        Show error notification
      </Button>
    </div>
  );
};

<ToastProvider maxVisible={2}>
  <Controls />
</ToastProvider>

Interactive documentation