Toaster
A brief message about something that has already happened — and that leaves on its own, so it can never be waiting for an answer.
Toaster
One toaster, mounted once at the app root, and every `toast()` call anywhere in the tree lands in it — no provider, no ref, no context to thread through. Mount a second one and the same toast renders twice, in two corners.
Usage
import { Toaster } from '@oceanic-hub/brand-system'Reach for it for the outcome of an action a person just took: saved, published, deleted,
failed. Never put a decision in one. It disappears on a timer, so a toast that asks a question
has hidden the question — that belongs in a Dialog, or an AlertDialog when there is no way
back. For a condition that stays true while the page is open — a read-only environment, a stale
export — the surface is an Alert, which does not leave.
toast() is re-exported from the same import, so nothing downstream reaches for the toast library
directly. That matters more than it looks: swapping the library out is a change
CONTRIBUTING.md keeps open, and a surface importing it by name is the one thing that would make
that expensive. Mount the toaster once, at the app root. Its store is a module singleton every
mounted toaster subscribes to, so a second one renders every toast a second time, in its own corner.
The brand's treatment reaches the toast through a stylesheet, not through a class list, and the
reason is worth knowing before you try to restyle one. The library injects its own sheet at
import time, unlayered, while every utility in this system sits in Tailwind's utilities
layer — and an unlayered declaration beats a layered one whatever its specificity. So for several
releases the class map this wrapper carried lost every declaration it made: measured on
2026-08-17, in both themes, a toast rendered on the library's own white ground, with a drop
shadow this system does not otherwise permit, an 8px radius, and rgb(237,237,237) on success,
error and information alike — the three status colours were one grey. @OCE-1881 replaced the class
map with styles/sonner.css, which is unlayered too and rebinds the library's own variables, so
the ground is elevated, the edge is a 1px hairline, the radius is 6px, the shadow is gone and
each status carries its own tone at 40%. A className of your own will still lose to the
library on any property that sheet does not already own — reach for the sheet, or for a
different component.
That inversion fixes the two traps the old arrangement had, and both are worth stating because consumers may remember them:
- Your
toastOptionsare now purely additive. They used to be spread shallowly over a branded default map, so passing anytoastOptionsof your own dropped the whole treatment in one go — a prop that read additive and was destructive. There is no map left to replace. - The theme is passed through, so the library is no longer pinned to its light variables. It
is read off the same
.dark, [data-theme="dark"]pair the token layer keys on, so the toaster cannot disagree with the page behind it.
Turning the library's rich colours on still replaces the status palette with its own, in
colours that never came from tokens.source.mjs. The stylesheet yields to it deliberately rather
than out-ranking it — an option that silently does nothing is the defect this component just spent
a ticket removing — but it remains the wrong thing to reach for, and it is no longer the only
thing that makes a status toast look like one.
The package draws a border for three of the library's five status types — success, error and
information — and none for warning or loading. A warning and a loading toast fall through to the
plain surface: not for want of a role, since working is this palette's warning tone, but because
the sheet has no warning rule. A gap, not a decision. So a warning toast is a plain toast whose
sentence has to do all the work — worth knowing before choosing it over an error. A loading toast
draws the library's own spinner, which the package does not style; prefer handing the work to
toast.promise, which reaches the same state through a path the package means to draw.
RTL is not supported. The library takes a direction and defaults to reading the document's, so a
right-to-left page would flip the toaster and nothing else. The refusal is recorded in
pairings.json under direction: nothing here has ever been laid out or measured
right-to-left.
Status
Naming a status sets the toast's type, which picks its icon and is what an assistive technology announces. One section rather than three: a toast is fired, never open, so three headings would show three identical buttons. Each toast now carries its own tone on the edge — done, stuck, info, at 40%, the same line every other status surface draws (@OCE-1881). A hairline at 40% is deliberately not the carrier, though: what tells them apart is the glyph and the sentence, and a tint is only ever allowed to agree with them.
Description
Put the outcome on the first line and the detail under it, for the reader who wants the detail and must not be made to read it. The detail drops a weight rather than becoming a paragraph — if it has to be read, it belongs on the page, not in something that leaves after four seconds.
An action
Give a toast one button when what just happened can be reversed or looked at. This is the affordance AlertDialog points at from the other side: if the result is undoable, do it and offer the undo here rather than stopping to ask first. One button only — a toast that leaves on its own must never be the only place a choice was available.
Promise
Hand the work itself over and one toast covers the whole span: it opens while the request is in flight and becomes the outcome in place, so a slow action never leaves a stale "working" toast behind next to its own result. Reach for it whenever the wait is long enough to notice and short enough that nobody navigates away.
Position
Toasts land bottom-right, out of the way of a form and near the buttons that fire them. Move a single toast when it reports on something at the other end of the screen — a header action, a bar pinned to the top — rather than moving the toaster, which takes every other toast with it.
API Reference
See the Toaster API page for every prop of every part, with types, defaults and the contract that pins them. It also documents toast — exported alongside the parts, and signatures rather than props.