Toast
A portaled, auto-dismissing notification queued through a manager hook.
Show codeHide code
Installation
import { ToastProvider, useToast } from "@makeplane/propel/components/toast";Usage
import { Button } from "@makeplane/propel/components/button";
import { Icon } from "@makeplane/propel/components/icon";
import { IconButton } from "@makeplane/propel/components/icon-button";
import { ToastProvider, useToast } from "@makeplane/propel/components/toast";
import { X } from "lucide-react";
const closeButton = (
<IconButton variant="ghost" size="xs" aria-label="Dismiss" icon={<Icon icon={X} />} />
);
function ToastTrigger() {
const { add } = useToast();
return (
<Button
stretch="auto"
variant="secondary"
size="sm"
label="Show notification"
onClick={() =>
add({
title: "Project created",
description: "Marketing site is ready for your team.",
data: { variant: "success" },
})
}
/>
);
}
export default function BasicDemo() {
return (
<ToastProvider close={closeButton}>
<ToastTrigger />
</ToastProvider>
);
}Examples
Variants
The required variant in a toast’s data selects its status icon and color: success, danger, info, warning, or neutral.
danger and warning toasts are treated as urgent: they’re announced assertively as role="alertdialog" (screen readers interrupt to read them immediately, instead of waiting politely) and stay open for 8 seconds instead of the usual 5 — enough time to read a failure reason before it auto-dismisses. This is automatic; no extra prop is needed. Tests that queried getByRole("dialog") for those variants should use alertdialog (often with { hidden: true }, since Base UI keeps the card aria-hidden until the viewport is focused).
priority and timeout are derived from variant on add and when an update changes urgency (e.g. danger → success). An explicit value in the same call always wins; restating the same variant (progress updates) leaves an existing custom timeout or priority alone — including timeout: 0 for persistent progress toasts.
Show codeHide code
With actions
Pass actions for a left-aligned cluster of up to two buttons, and primaryAction for a right-aligned button.
Show codeHide code
With progress
Set progress (0–100) to report a long-running task; a thin bar renders between the description and the action row.
Show codeHide code
Promise
useToast().promise(promise, { loading, success, error }) queues a loading toast, then updates it in place when the promise settles.
Show codeHide code
API Reference
ToastProvider
Wraps the app and renders the toast viewport. Mount it once near the root, then queue toasts with `useToast().add({ title, description, data: { variant } })`. Composes the atomic `elements/toast` parts (Provider + Portal + Viewport) and the manager-driven {@link ToastList}.
Toast
A single styled toast: status icon (auto-selected from `toast.data.variant`), title, description, optional action buttons (from `toast.data.actions` / `primaryAction`), and a close button. Rendered automatically by `ToastProvider` for each queued toast — you normally don't render this directly.