Toast
A notification: status icon, visually hidden severity text, title, body, footer and a Dismiss button. Its parts are direct children: Toast.Title (the title row, with an optional action), Toast.Body (with an optional subtitle) and Toast.Footer (a row of actions); a Toast.Close anywhere inside makes its child dismiss the toast. The title prop and plain children are the 0.5 form and render as a Title and a Body.
Dispatch it with useToastController().dispatchToast(<Toast>โฆ</Toast>), or render it yourself.
- **In a Toaster**: not a live region itself; the Toaster announces it once per dispatch through its permanent live regions (its severity text, then its title, body and the labels of its actions, never the Dismiss button, or, after the severity text, the dispatch's announcement), politely or, for error, assertively, and names its container by the severity text and title. Every Toast there shows the Dismiss button.
- **On its own** (your own container, an inline notice): a live region, as in 0.4 โ role="status" with aria-live="polite", or role="alert" with aria-live="assertive" for error (override with role/aria-live). A live region that is added together with its text is not announced by every screen reader, so render the Toast in advance and change its content, or dispatch it through a Toaster.
Sub-components are also exported under flat names (ToastTitle, ToastBody, ToastFooter, ToastClose): React Server Components import those, because dotted access (Toast.Title) needs a client file.
Examples
Default
export const Default: Story = {};Success
export const Success: Story = {
args: {
title: 'Success',
status: 'success',
children: 'Operation completed successfully.',
},
};Warning
export const Warning: Story = {
args: {
title: 'Warning',
status: 'warning',
children: 'Please review the details.',
},
};Error
export const Error: Story = {
args: {
title: 'Error',
status: 'error',
children: 'Something went wrong.',
},
};With Dismiss
export const WithDismiss: Story = {
args: {
title: 'Dismissible',
children: 'Click the X to dismiss.',
onDismiss: fn(),
},
render: (args) => <DismissibleToast {...args} />,
};Toaster Example
export const ToasterExample: Story = {
args: {
title: 'Saved',
status: 'success',
children: 'Your changes were saved.',
},
render: (args) => (
<Toaster>
<ToasterDemo {...args} />
</Toaster>
),
};Toaster Top Start
export const ToasterTopStart: Story = {
args: {
title: 'Heads up',
status: 'warning',
children: 'Toasts appear at the top start corner.',
},
render: (args) => (
<Toaster position="top-start">
<ToasterDemo {...args} />
</Toaster>
),
};Limit
export const Limit: Story = {
args: {
title: 'File uploaded',
status: 'success',
children: 'The file is ready to share.',
},
render: (args) => (
<Toaster limit={3}>
<BurstDemo {...args} />
</Toaster>
),
};Dismiss All
export const DismissAll: Story = {
args: {
title: 'Sync conflict',
status: 'warning',
children: 'Review the changed files.',
},
render: (args) => (
<Toaster>
<DismissAllDemo {...args} />
</Toaster>
),
};Motion
export const Motion: Story = {
args: {
title: 'Comment added',
status: 'info',
children: 'Kat replied to your comment.',
},
render: function MotionToaster(args) {
const cases = motionCases(fadeAndCollapse);
const [label, setLabel] = React.useState(cases[0].label);
const { motion } = cases.find((option) => option.label === label) ?? cases[0];
return (
<div className="flex flex-col gap-4">
<RadioGroup
aria-label="Toast motion"
orientation="horizontal"
value={label}
onValueChange={setLabel}
>
{cases.map((option) => (
<RadioItem key={option.label} value={option.label} label={option.label} />
))}
</RadioGroup>
<Toaster motion={motion}>
<DismissAllDemo {...args} />
</Toaster>
</div>
);
},
};Toaster Beside Drawer
export const ToasterBesideDrawer: Story = {
args: {
title: 'Filters saved',
status: 'success',
children: 'Dismiss this toast with its button.',
},
render: (args) => (
<Toaster>
<DrawerWithToasts {...args} />
</Toaster>
),
};Parts
export const Parts: Story = {
args: {
status: 'success',
title: 'Backup complete',
children: 'All 128 files were copied to the archive.',
},
render: (args) => (
<Toaster>
<PartsDemo {...args} />
</Toaster>
),
};Title Action
export const TitleAction: Story = {
args: { status: 'info', title: 'Message deleted', onDismiss: fn() },
render: ({ title, ...args }) => (
<DismissibleToast {...args}>
<Toast.Title
action={
<Toast.Close>
<Button size="small" appearance="subtle">
Undo
</Button>
</Toast.Close>
}
>
{title}
</Toast.Title>
</DismissibleToast>
),
};Custom Icon
export const CustomIcon: Story = {
args: { status: 'info', title: 'Reminder', children: 'Stand-up starts in 5 minutes.' },
render: (args) => <Toast {...args} icon={<BellIcon />} />,
};Standalone
export const Standalone: Story = {
args: {
status: 'warning',
title: 'Storage almost full',
children: 'You have used 95% of your storage.',
onDismiss: fn(),
},
render: ({ title, children, ...args }) => (
<DismissibleToast {...args}>
<Toast.Title>{title}</Toast.Title>
<Toast.Body>{children}</Toast.Body>
<Toast.Footer>
<Button size="small">Manage storage</Button>
</Toast.Footer>
</DismissibleToast>
),
};Rich Content
Undone 0 times.
export const RichContent: Story = {
args: { status: 'success', title: 'Email sent', children: 'Your message was delivered.' },
render: (args) => (
<Toaster>
<RichContentDemo {...args} />
</Toaster>
),
};Custom Content
export const CustomContent: Story = {
args: { status: 'warning', children: 'Your session expires in 5 minutes.' },
render: (args) => (
<Toaster>
<CustomContentDemo {...args} />
</Toaster>
),
};Progress Toast
export const ProgressToast: Story = {
args: { title: 'Uploading report.pdf', children: '3 of 10 MB' },
render: (args) => (
<Toaster>
<ProgressToastDemo {...args} />
</Toaster>
),
};Keyboard Shortcut
Show a toast, then press Alt+Shift+N to move focus to it.
export const KeyboardShortcut: Story = {
args: { status: 'info', title: 'New comment', children: 'Ada replied to your review.' },
render: (args) => (
<Toaster shortcuts={{ focus: altShiftN }}>
<div className="flex flex-col items-start gap-2">
<p className="text-wave-body-1 text-wave-foreground">
Show a toast, then press Alt+Shift+N to move focus to it.
</p>
<ToasterDemo {...args} />
</div>
</Toaster>
),
};From Outside React
export const FromOutsideReact: Story = {
args: {
status: 'success',
title: 'Export ready',
children: 'report.csv was saved to your downloads.',
},
render: (args) => (
<Toaster toaster={storyToaster}>
<Button appearance="primary" onClick={() => notifyExportReady(args)}>
Export
</Button>
</Toaster>
),
};Inverted
export const Inverted: Story = {
args: {
title: 'Link copied',
status: 'success',
appearance: 'inverted',
children: 'Share it anywhere.',
},
render: (args) => <DismissibleToast {...args} />,
};Centered And Offset
export const CenteredAndOffset: Story = {
render: () => (
<Toaster position="top" offset={{ vertical: 48 }}>
<OptionsDemo
label="Show a centered toast"
options={{ title: 'Centered', body: '48px from the top.' }}
/>
</Toaster>
),
};Per Toast Position
export const PerToastPosition: Story = {
render: () => (
<Toaster>
<PerToastPositionDemo />
</Toaster>
),
};Politeness
export const Politeness: Story = {
render: () => (
<Toaster>
<OptionsDemo
label="Show a calm error"
options={{
title: 'Sync failed',
status: 'error',
politeness: 'polite',
body: 'It will retry.',
}}
/>
</Toaster>
),
};Priority
export const Priority: Story = {
render: () => (
<Toaster limit={1}>
<PriorityDemo />
</Toaster>
),
};Lifecycle
Lifecycle: none yet
export const Lifecycle: Story = {
render: () => (
<Toaster>
<LifecycleDemo />
</Toaster>
),
};Without Dismiss Button
export const WithoutDismissButton: Story = {
render: () => (
<Toaster>
<OptionsDemo
label="Show a toast without a button"
options={{
title: 'Syncing',
body: 'Keep this window open.',
showDismissButton: false,
pauseOnHover: false,
}}
/>
</Toaster>
),
};Custom Announcer
Announced: nothing yet
export const CustomAnnouncer: Story = {
render: () => <CustomAnnouncerDemo />,
};Inline
export const Inline: Story = {
render: () => (
<Toaster inline>
<OptionsDemo label="Show an inline toast" options={{ title: 'Inline', body: 'No portal.' }} />
</Toaster>
),
};Props
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
status | 'success' | 'warning' | 'error' | 'info' | No | 'info' | Status level controlling the toast color, icon and status text. |
appearance | 'default' | 'inverted' | No | 'default' |
|
showDismissButton | boolean | No | true in a Toaster, else whether `onDismiss` is given | Whether the Dismiss button shows. Inside a Toaster it shows by default, a |
title | string | No | Title text (the 0.5 form; renders as a | |
statusLabel | string | No | Visually hidden status text read before the toast ( | |
icon | Slot<'span'> | No | Replaces the status icon (decorative, | |
onDismiss | () => void | No | Called when the Dismiss button or a | |
dismissLabel | string | No | 'Dismiss' | Accessible name of the dismiss button. Pass a translation for other languages. |
ref | React.Ref<HTMLDivElement> | No | Ref to the root | |
slotProps | { content?: SlotPart<'div'>; dismissButton?: SlotPart<'button'> } | No | Props for the elements the Toast draws around your content, by part, merged into the part's own: your classes after the part's (yours win a conflict), your styles over its styles, your attributes and handlers added, your ref beside its ref. Every attribute the Toast sets on a part is locked and keeps the Toast's value; you add the attributes it does not set. A part takes no |
Any other prop is passed to the element it renders (HTMLDivElement).
Parts
contentdismissButtonToast.TitleToast.BodyToast.FooterToast.Close
Stable class names
| Part | Class |
|---|---|
root | wave-toast |
icon | wave-toast__icon |
content | wave-toast__content |
dismissButton | wave-toast__dismiss-button |