Toast
Toast notifications provide brief, non-intrusive feedback about user actions. Use toasts to display success messages, errors, warnings, or general information.
Overview
Toasts are temporary notification messages that appear to inform users about the result of an action or to provide important information. They typically appear at the edge of the screen and automatically dismiss after a few seconds, though users can also manually dismiss them.
All toast styles are built using design tokens, ensuring consistency across themes and hues. Use the interactive playground below to explore all available combinations.
Interactive Playground
Use the controls to customize the toast and see how it looks in real-time. Toggle between themes and hues to see how toasts adapt to different contexts.
<Toast />Anatomy
A toast consists of several parts that work together to create a cohesive notification element.
padding, border-radius, shadowOptional leading icon (24px)--body-regular-text-sizeOptional action (e.g., "Undo")Optional dismiss control (24px)Variants & States
Toasts come in different variants to communicate different types of information.
Default
General information notifications using page-secondary background and neutral foreground.
Success
Success notifications for positive actions and confirmations.
Error
Error notifications for failures and critical issues.
Warning
Warning notifications for cautionary states and important alerts.
Without Action
Toasts can be displayed without an action button for simple notifications.
Without Icon
Toasts can be displayed without a leading icon for a cleaner look.
Non-dismissible
Toasts can be configured to not show a close button, requiring automatic dismissal.
Full Width
Toasts can stretch to fill the full width of their container.
Usage Guidelines
- Use toasts for non-critical, temporary notifications.
- Keep messages concise and actionable.
- Use appropriate variants based on message type (success, error, warning).
- Provide action buttons for reversible actions (e.g., "Undo").
- Allow users to dismiss toasts manually.
- Position toasts consistently (typically top-right or bottom-right).
- Limit the number of visible toasts to avoid overwhelming users.
- Don't use toasts for critical errors that require immediate attention.
- Don't use toasts for information that users need to reference later.
- Don't stack too many toasts at once.
- Don't use vague or unclear messages.
- Don't make toasts too large or intrusive.
- Don't use toasts for primary navigation or actions.
- Don't auto-dismiss error toasts too quickly.
Accessibility
- Toasts should use appropriate ARIA roles (
role="status"for informational,role="alert"for errors). - Use
aria-liveregions to announce toast messages to screen readers. - Ensure sufficient color contrast for all toast variants.
- Provide keyboard-accessible dismiss controls.
- Allow sufficient time for users to read and interact with toasts.
- Provide clear focus management when toasts appear.
API Reference
Toast component props and types.
ToastProps
interface ToastProps {
variant?: "default" | "success" | "error" | "warning";
message?: React.ReactNode;
actionLabel?: string;
onAction?: () => void;
showAction?: boolean;
dismissible?: boolean;
onDismiss?: () => void;
leadingIcon?: React.ReactNode;
showIcon?: boolean;
closeIcon?: React.ReactNode;
fullWidth?: boolean;
duration?: number;
}Props
variant"default" | "success" | "error" | "warning""default"messageReact.ReactNode"Toast Info"actionLabelstring"Undo"showActionbooleantruedismissiblebooleantrueshowIconbooleantruefullWidthbooleanfalsedurationnumberundefinedUsage Examples
Copyable code snippets for common toast use cases.
Basic Toast
import { Toast } from 'beacon-ui';
<Toast />All Variants
import { Toast } from 'beacon-ui';
<Toast variant="default" />
<Toast variant="success" />
<Toast variant="error" />
<Toast variant="warning" />With Custom Message
import { Toast } from 'beacon-ui';
<Toast message="File saved successfully" />With Action Handler
import { Toast } from 'beacon-ui';
<Toast
message="Item deleted"
actionLabel="Undo"
onAction={() => console.log("Undo clicked")}
onDismiss={() => console.log("Dismissed")}
/>Full Width
import { Toast } from 'beacon-ui';
<Toast fullWidth message="This toast spans the full width" />