Toast
A short, temporary message about an action, announced to assistive technology.
Use a toast to confirm an action or report a failure without interrupting people, for example after saving or copying. For information that must stay on screen, use an alert.
"use client";
import { Button, toast } from "@aloxe/react";
export default function ToastTones() {
return (
<div className="flex flex-wrap items-center gap-3">
<Button variant="secondary" onClick={() => toast("Link copied")}>
Neutral
</Button>
<Button variant="secondary" onClick={() => toast("Changes saved", { tone: "success" })}>
Success
</Button>
<Button
variant="secondary"
onClick={() =>
toast("Couldn't save changes", {
tone: "danger",
description: "Check your connection and try again.",
})
}
>
Danger
</Button>
</div>
);
}Installation
npm i @aloxe/react @aloxe/tokensThen add the CSS imports from Installation.
Usage
Render one Toaster near the root of your app, then call toast() from any event handler.
// app/layout.tsx
import { Toaster } from "@aloxe/react";
<body>
{children}
<Toaster />
</body>import { toast } from "@aloxe/react";
toast("Changes saved", { tone: "success" });Toasts sit at the bottom of the screen, bottom right from 640 px. They close after 5 seconds, unless they have an action. The examples on this page use the one Toaster mounted in this site's root layout.
Examples
With an action
An action, such as Undo, keeps the toast open until it is used or closed, so nobody runs out of time. Reusing the id replaces the toast in place.
"use client";
import { Button, toast } from "@aloxe/react";
export default function ToastWithAction() {
function archive() {
toast("Conversation archived", {
id: "archive",
action: {
label: "Undo",
onClick: () => toast("Conversation restored", { id: "archive", tone: "success" }),
},
});
}
return (
<Button variant="secondary" onClick={archive}>
Archive conversation
</Button>
);
}With a description
A second line for detail. Give longer toasts a longer timeout.
"use client";
import { Button, toast } from "@aloxe/react";
export default function ToastWithDescription() {
return (
<Button
variant="secondary"
onClick={() =>
toast("Export ready", {
tone: "success",
description: "invoices-2026.csv, 214 rows",
timeout: 8000,
})
}
>
Export invoices
</Button>
);
}Accessibility
| Key | Action |
|---|---|
| F6 | Moves focus to the notifications area. |
| Tab | Moves between the action and the close button. |
| Escape | Closes the focused toast. |
- The toaster is a live region labelled "Notifications". Neutral and success toasts are announced politely; danger toasts are announced right away.
- Timers pause while the pointer is over a toast or focus is in one.
- Anything a toast offers, such as Undo, should also be possible elsewhere in the page.
API reference
Every part accepts className and renders a data-aloxe attribute you can target in CSS, such as [data-aloxe="toast"].
Toaster
| Prop | Type | Default | Description |
|---|---|---|---|
| timeout | number | 5000 | Default time in ms before a toast closes. Toasts with an action stay until closed. |
| limit | number | 3 | How many toasts show at once. Others wait for a free slot. |
| closeLabel | string | "Dismiss" | Accessible name of each toast's close button. |
| className | string | Classes for the viewport, e.g. a different position. |
toast(message, options)
| Prop | Type | Default | Description |
|---|---|---|---|
| tone | "neutral" | "success" | "danger" | "neutral" | Sets the icon. Danger toasts are announced assertively. |
| description | ReactNode | A second, quieter line. | |
| action | { label: string; onClick: () => void } | One button, e.g. Undo. A toast with an action does not close on its own. | |
| timeout | number | Time in ms before this toast closes; 0 keeps it open. | |
| id | string | Reusing an id replaces that toast instead of adding one. | |
| onClose | () => void | Called when the toast starts closing. |
Figma
Matches the Toast component. Figma Tone (Neutral, Success, Danger) maps to tone, Message to the first argument, and Show action with Action to action.
See Figma for where to get the file and how its names map to code.