Toast

A short note in the corner about something that happened out of sight. It goes away on its own, and stacks when several arrive.

Kinds

Each kind has its intent's icon, so colour is never the only cue.

toast.success('Invite sent', { description: 'ola@vestlandmarin.no' });

toast('Mission archived', {
	action: { label: 'Undo', onClick: restore },
});

toast.promise(exportCsv(), {
	loading: 'Exporting 1 248 measurements...',
	success: 'Export ready',
	error: 'Export failed',
});

Undo and background work

Set up

<!-- Once, in the root layout -->
<Toaster theme={dark ? 'dark' : 'light'} />

Rules

  • For what happens out of sight: something sent, a page left, work finishing in the background. A change you can see on the page needs no toast; a save button’s success state is enough.
  • Say what happened, past tense, with the thing named: "Invite sent", not "Success!".
  • An error that needs fixing belongs next to what’s wrong: a field error or a banner. A toast is for errors with nothing to point at.
  • Undo instead of asking first, where the action can be reversed.
  • One line of title; the description for the name or number it was about.