Toastv1.1.4Documentation Under Review
Display temporary notification messages with customizable variants, actions, and automatic dismissal. Built on Sonner for smooth animations and queuing.
Prefer AI-assisted development?
Catalyst Toast provides a flexible notification system built on Sonner, adding design-token-matched variants, compound sub-components, and accessibility defaults so you can ship production-ready toast notifications without extra configuration.
Installation
npm install @pmi/catalyst-toastimport {
ToastProvider,
ToastContent,
ToastTitle,
ToastDescription,
ToastIcon,
ToastAction,
ToastDismiss,
renderToastRoot,
} from '@pmi/catalyst-toast'Place ToastProvider once near the root of your app so the Sonner Toaster portal is available to every page. A Next.js root layout is a typical location:
// app/layout.tsx
import { ToastProvider } from '@pmi/catalyst-toast';
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html>
<body>
<ToastProvider>
{children}
</ToastProvider>
</body>
</html>
);
}Variants
General
The default neutral style for informational messages.
Brand
PMI-branded violet style for product announcements and updates.
Warning
Caution style using yellow tones for non-critical alerts.
Success
Positive confirmation style using green tones.
Danger
Error or destructive-action style using red tones.
API Reference
Toast is a compound component. The sections below summarize the API surface for each part.
ToastProvider
Renders the Sonner Toaster portal. Mount it once at the app root (e.g. in your layout file) so every page can fire toasts via renderToastRoot. Also accepts all Sonner ToasterProps (e.g. position, expand, richColors, duration, theme) and the unstyled prop.
Prop
Type
ToastContent
Root container passed as the children argument to renderToastRoot. Provides the rounded card layout and variant-matched background, border, and shadow.
Prop
Type
ToastTitle
Headline text rendered as an <h6> with medium weight and variant-matched foreground color.
Prop
Type
ToastDescription
Supporting body text rendered as a <p>. Accepts the same props as ToastTitle above.
ToastIcon
Styled icon container at the leading edge of the toast. Applies variant-matched foreground color so the icon contrasts correctly against the toast background.
Prop
Type
ToastAction
Call-to-action button that auto-dismisses the toast after the action is triggered. Supports asChild for rendering a custom element such as a link.
Prop
Type
ToastDismiss
Close button positioned at the top-left corner of the toast. Calls sonnerToast.dismiss(id) on click.
Prop
Type
renderToastRoot
Imperative function that fires a toast via the Sonner API:
renderToastRoot(children: React.ReactNode, props: ToastRootProps): string | number| Parameter | Type | Description |
|---|---|---|
children | React.ReactNode | The ToastContent tree to render |
props.id | string | number | Unique toast identifier — pass the same value to ToastContent, ToastAction, and ToastDismiss |
props.duration | number | Auto-dismiss duration in milliseconds (default: 5000) |
Accepts all additional Sonner ToastT options via props.
Accessibility
Toast is designed to meet WCAG 2.2 AA standards. Because toasts appear without a direct user action, choosing the correct live region semantics is critical for screen reader users.
Keyboard Interactions
| Key | Action |
|---|---|
Tab | Moves focus into the toast list managed by Sonner |
Shift + Tab | Moves focus backward through interactive toast elements |
Enter / Space | Activates the focused action or dismiss button |
ARIA
- Use
role="status"witharia-live="polite"onToastContentfor non-critical, informational messages (confirmations, success feedback). This satisfies WCAG 4.1.3 Status Messages. - Use
role="alert"witharia-live="assertive"onToastContentfor urgent messages that require immediate attention (errors, session expiry warnings). - Set
aria-atomic={true}when the entire toast should be announced as a unit on each change. - Always provide
aria-labelonToastDismissbuttons (e.g.aria-label="Close"). Icon-only buttons have no visible text and require an explicit accessible name (WCAG 4.1.2 Name, Role, Value). - Set
aria-hidden={true}onToastIconwhen the icon is decorative and the adjacent text already conveys the meaning (WCAG 1.1.1 Non-text Content). ToastProvidersetscontainerAriaLabel=""andhotkey={['']}on the underlying SonnerToasterto prevent duplicate announcements from the container element.- All color variants meet the 4.5:1 text contrast ratio required by WCAG 1.4.3 Contrast Minimum in both light and dark mode.
Choosing the Right Component
Use Toast when you need a brief, auto-dismissing notification triggered by a user action. Reach for a different primitive when:
| If you need... | Use instead |
|---|---|
| A persistent, inline status message that stays in the page flow | Alert |
| A blocking message that requires the user to make a decision before continuing | Dialog |