Components · Feedback
Toast
A dark floating notice that confirms the result of something the person just did, disappears after a few seconds, and can offer View or Undo.
import { Toast } from "@botiverse/raft-ui";A toast is the receipt for something the person just did: a message sent, a setting saved, an agent finishing the job they just gave it. It floats above the page on the dark HUD, says one sentence, and goes away after a few seconds. It can carry one text action, such as View or Undo.
When to use
Never put anything in a toast that would confuse people if they missed it (Choosing a component).
Anatomy
ToastProvider: holds the toast manager and, by default, renders the viewport. Mount it once near the root: the default manager (toast.*) takes its timing (timeout,actionTimeout) from the one provider that uses it, so two providers on the default manager would overwrite each other's. Give a second provider its owntoastManager.toast: the command API (toast.success,toast.error, …) for the default manager.useToast()returns the same commands for the nearestToastProvider's manager (Toasts in another window).ToastViewport: where toasts appear on screen.ToastPositionerandToastArrowanchor a toast to an element instead.ToastRootandToastContent: one toast and its layout.ToastIcon: optional. Who did it (an avatar), or the intent's icon when there is no "who". Never a status light for the toast's intent: a status light never says what kind of notice this is (success, info, warning, error). A status light keeps its own meanings, whether an agent, a person or a computer is working or online, a task's status, and the square attention dot that marks something waiting or unread; a notice about one of those things may still show that thing's light inside it (Status).ToastBody, holdingToastTitle(required) and an optionalToastDescription, both intext-callout(Typography): 14/20 on a phone, 14/22 on a desktop, like a banner.ToastIconis one line of that text tall, so the icon stays on the title's line: a 16px icon, centered in a 20px column 12px before the title, as is an avatar (A mark that leads text).ToastActions: optional, holding oneToastAction.ToastClose(Dismiss) is there for a toast that doesn't close by itself, which Raft doesn't use; the command API shows it only withdismissible: true. Text Dismiss comes before the action, as in a banner; a × (ToastCloseholding anything but text, such as an icon) always ends the row, after the action, where a dialog's or a banner's × sits, so people find the close in one place on every surface (Artea, 2026-11-21, #proj-desk).ToastCloseplaces itself by what it holds; don't reorder it.ToastProgress: an optional line that shows the time left before it closes.
Leave out a part you don't need instead of rendering it empty.
Variants
The intent sets the icon in ToastIcon, the same icon a banner of that intent leads with (Banner). When the toast is about someone, show their avatar there instead.
With the toast command API, pass the avatar as leading. It takes the icon's place in ToastIcon, hidden from assistive technology.
Behavior
- A toast closes on its own: after the provider's
timeout, 5 seconds by default, and after itsactionTimeout, 8 seconds, when it has an action or is anerror, so there is time to read and then act. Thetoastcommand API appliesactionTimeout; with a manager of your own, passtimeout: 8000to such a toast. Hovering, focusing or touching it pauses the timer. - People can swipe a toast away or press Esc while it has focus (F6 moves focus to the toasts). There is no Dismiss: every toast closes by itself, and a second text action beside Undo would read as a second choice.
- Pressing the toast's action closes the toast, and focus must not go with it: pressed from the keyboard (F6, then Enter), focus would be left on nothing. Move it to what the action brought back: Undo after a deletion focuses the item made again, at the place it is drawn. Where the item isn't drawn yet, focus waits on the region that will hold it and moves to the item once it appears; where nothing on screen draws it, focus stays on that region. Move it the same way when the action is pressed with a pointer, since the toast's button took focus and goes with it; the ring shows only after keyboard input, so a pointer press shows none. Never leave focus on the body or on the toast's old place, and once the person has moved focus themselves, leave it where they put it (Kirby, 2026-11-06, #proj-workspace:#200). The region shows a focus ring after keyboard input, inside its edge as an item's is (States); on a region whose children have backgrounds, draw it as a 2px outline offset inward (
keyboard:focus-visible:outline-2 keyboard:focus-visible:outline-solid keyboard:focus-visible:-outline-offset-2), since the children would cover an inset shadow. Nameoutline-solid: a region that setsoutline-noneat rest has its outline style at none, andoutline-2alone keeps it so, drawing nothing (slock #13342). - One toast shows at a time (
limit, 1 by default). A new toast replaces the one on screen at once, and the replaced one is closed, not queued: it doesn't come back when the new one goes. - An anchored toast opens next to the control that caused it (
ToastPositioner), keeps clear of host frame insets, and hides while its anchor is out of view.
Where it appears
Toasts appear at the bottom center (viewportPlacement="bottom-center"; stdrc, 2026-10-23), just above whatever holds the bottom of the page: the composer on a conversation page, on a desktop as on a phone; the tab bar on a phone's top-level page; the on-screen keyboard while it is up. Where nothing holds the bottom (a desktop page with no composer), it is the bottom of the window. At the bottom of the window, a toast covered the lower half of the composer and its tools on a desktop while the person was typing (Scout, 2026-11-12, #triage:abdb39d9); one rule for every width also keeps it and the new-version banner in one place.
What counts as the bottom of the page is what sits against it and can be seen (Scout, 2026-11-12, #triage:abdb39d9):
- Only a bar that holds the page's bottom edge counts: the composer of a conversation, a phone's tab bar. A field floating in the middle of the page (in a dialog, in a comment bubble) doesn't lift the toast, which would float into the middle of the window.
- With the conversation beside a thread or another column, the taller of their bottom bars counts, so the toast clears both.
- What is covered doesn't count. While a dialog or an Artifact's cover lies over the conversation, its composer behind them is not the bottom of the page, and the toast sits at the bottom of the window; when they close, it goes back above the composer.
Only the app knows where that is, so it sets --toast-viewport-bottom to the distance from the bottom of the window to that thing's top edge, on :root or with viewportClassName, and updates it as the composer grows or the keyboard opens. The toast's bottom edge sits 16px above it, and never lower than 16px above the system's home indicator (env(safe-area-inset-bottom)), so on a phone it stays clear of it even when the variable is unset.
The banner that says a new version is out holds the same place, above the composer or the tab bar: where there is no top bar (a phone, the web under 768px), and on a desktop once a day has passed without the update (The web top bar). It stays until the person chooses Dismiss or Update; toasts stack above it, so it never covers one and one never covers it (Feedback).
While a toast shows, it doesn't move down with the page (asked by artin, 2026-11-07). When the page changes under it (another page's bar is lower, or a page still loading has nothing at its bottom yet), the app keeps the tallest page edge (composer, tab bar) it has seen since the toast appeared, until the last toast is gone, and moves up when something taller appears, so it never covers the composer. The keyboard isn't part of that. While it is up, the toast follows the live edge, since the composer rides on the keyboard, and the app holds nothing it measures in that time. When the keyboard closes, the toast comes back to the held height. The Raft app does the same (RaftToastHost).
:root {
--toast-viewport-bottom: 72px; /* the top edge of the composer */
}A surface whose bottom is taken by something a toast must not cover can pass viewportPlacement="top-center" instead; the app then sets --toast-viewport-top to where its header ends, and the toast sits 16px under it, never higher than 16px under the status bar (env(safe-area-inset-top)).
A toast swipes away the way it came: down or right from the bottom, up from the top. ToastRoot takes the direction from its ToastViewport; pass swipeDirection to change it.
While a modal dialog, sheet or lightbox is open, show only the toasts it causes and that leave it open, without an action. Toasts draw above dialogs, lightboxes and their scrims (Layer order).
Toasts in another window
A part of the app drawn in a second window (an Electron window opened with window.open, under PortalContainerProvider) shows the toasts raised there in that window. It mounts a second ToastProvider inside its subtree, with a manager of its own, and raises them with useToast():
function SecondWindow({ container }: { container: HTMLElement }) {
const [manager] = useState(() => createToastManager());
return (
<PortalContainerProvider container={container}>
<ToastProvider toastManager={manager}>
<SecondWindowContent />
</ToastProvider>
</PortalContainerProvider>
);
}
function SaveButton() {
const toast = useToast();
return <Button onClick={() => toast.success("Saved")}>Save</Button>;
}- The provider's viewport renders in the window: its
portalContainerfalls back to thePortalContainerProvider's container. useToast()gives the command API (success,error,action,actionTimeoutand the rest, astoast.*) bound to the nearest provider's manager: inside the subtree that is the window's provider.useToastManager()reaches the same provider with Base UI's raw options.toast.*stays bound to the default manager and so to the main window's provider. A call made outside any component (a store, a request's callback) can't know which window it is for: pass it the window's commands, or calltoast.*for the main window.- Give the second provider its own
toastManager: two providers on the default manager both show everytoast.*toast, one in each window.
The toast follows the provider it is raised through, not the document the press came from. A toast is often raised after an await, from a store or a request's callback, where the press and its document are gone, and focus may have moved to the other window by then; the provider the code runs under is known wherever it runs.
Content
- Write one sentence: who, what they did, and the result. Put anything more in
ToastDescription, inforeground-on-hud-muted. It is not one of the explanation slots that take only aHelperText: it takes any content. On an error, the caller writes the recovery there ("Check your connection, then try again"). - Label the action View or Undo, or another verb in sentence case.
- Set IDs, counts and times in Space Mono (Typography).
Accessibility
Toast wraps Base UI's Toast, which announces each toast in a live region and keeps it open while it has focus.
- Make
ToastTitlecarry the whole meaning. The icon inToastIconis hidden from assistive technology, and so isToastProgress. - Hide an avatar in
ToastIconwitharia-hidden; the name is already in the text. The command API'sleadingdoes this for you. - Pass
loadingLabelto aToastActionthat shows a loading state, so its spinner says what it waits for.
Rules
- Show at most one toast at a time; a new one replaces it.
- Use
layer-hudfor every toast, withforeground-on-hudtext. Don't tint a toast with an intent color, and never use yellow: notices are neutral (Color). - Make the action a bold text action that underlines on hover (
ToastAction), never a button. Never put a colored button in a toast. - Give a toast at most one action besides closing it.
- Make View, or any action that opens something, a shortcut only: what it opens must also be reachable where it lives, because the toast goes away by itself. Undo is different: it is the way back for something that has just left its place, which is why the toast carries it (Feedback).
API
ToastAction
Also takes the attributes of its element.
ToastActions
Takes the attributes of its element.
ToastArrow
Also takes the attributes of its element.
ToastBody
Takes the attributes of its element.
ToastClose
Also takes the attributes of its element.
ToastContent, ToastDescription
Also takes the attributes of its element.
ToastIcon
Takes the attributes of its element.
ToastPortal
Also takes the attributes of its element.
ToastPositioner
Also takes the attributes of its element.
ToastProgress
Also takes the attributes of its element.
ToastProvider
ToastRoot
Also takes the attributes of its element.
ToastTitle
Also takes the attributes of its element.
ToastViewport
Also takes the attributes of its element.
Related
Changes
- 0.103.4 · FixedFrame insets (
Popover,DropdownMenu,ContextMenu,Select,Combobox,ComboboxSelect,Tooltip,PreviewCard,CoachMark,NotificationCenter,MobileNavServerPopover,ToastPositioner,ComposerSuggestionList):--raft-frame-inset-startand--raft-frame-inset-endare the corners of the window's top band (--raft-frame-inset-top), not columns down its sides. A popup anchored under the band keeps its own padding from the window's edge; only one anchored in the band (a title-bar control, or a context menu opened in the bar) keeps 8px clear of a corner. - 0.103.0 · Breaking ChangesExplanation slots take only a
HelperText:FieldDescription,FormSection'sdescription, aChoiceListitem'sdescription,SelectItemDescription,DialogDescription,AlertDialogDescription,DrawerDescription,PopoverDescription,EmptyStateDescription,CardDescription,CardFooter,BannerDescription,DialogFooterNote(work in progress),MessageActionCardHint,MessageActionCardHeaderDescription,MessageActionCardScopeDescriptionandMessageActionCardActionsNote. AHelperTextis made only byhelperText(content, { why, about }):contentis anyReactNode(a string, a formatted message, aTextLinkinside a sentence),whyis"consequence","audience"or"recovery", andaboutnames the thing the line is about. Each slot renders the content withdata-whyanddata-about, and in development warns once when it is given anything else, which it still renders.ToastDescription,NotificationCenterItemBody,EmptyStateTitle,ListRowDescriptionand the status and data parts are unchanged. - 0.102.19 · FixedToast: a × (
ToastCloseholding an icon, or anything but text) ends the row, after the action; text Dismiss stays before it.ToastClosesetsdata-content="icon"or"text"and places itself by it. - 0.102.9 · AddedToast:
useToast()returns the command API (success,error,action,actionTimeout, …) bound to the nearestToastProvider's manager;toastitself under a provider on the default manager or none. New exportToastCommands. - 0.22.0 · Changedtoast command API:
toast.info,toast.success,toast.warningandtoast.errorlead with their intent's icon inToastIconinstead of a status pixel. The calls,icon: falseandleadingare unchanged, and aleadingnode still takes the icon's place. - 0.9.6 · Added
toast.add/info/success/warning/error(title, { leading })puts a node, such as a person's avatar, inToastIconin place of the status pixel. It isaria-hiddenand still shows withicon: false. Calls withoutleadingrender exactly as before. - 0.5.35 · Changed
ToastContentmeasures its rendered content and writesdata-has-icon,data-has-descriptionanddata-has-actionson itself; the content layout keys off these attributes instead of descendant selectors.