Toast
Toast surfaces brief, non-blocking feedback about the result of a user action or system event.
import { Toast } from '@/components/ui/wideset/toast/Toast';
<Toast status="success" onDismiss={() => dismiss()}>
<Toast.Message>Workspace synced</Toast.Message>
<Toast.Action>Open</Toast.Action>
</Toast>Installation
pnpm dlx wideset add toast
Copies the component and any Wideset components it uses into your project.
Examples
Variants
basic is one line with an optional action, for a short confirmation such as "Profile updated". expanded adds room for a description, a footer and a progress bar, for a task that is still running or needs a sentence of explanation. In an app, show toasts with useToast() inside a ToastProvider; it stacks them and closes them after their duration.
import { Toast } from '@/components/ui/wideset/toast/Toast';
export default function ToastVariants() {
return (
<div className="gap-ws-9 flex w-[25rem] max-w-full flex-col">
<Toast variant="basic" status="info" onDismiss={() => {}}>
<Toast.Message>Profile updated</Toast.Message>
<Toast.Action>Undo</Toast.Action>
</Toast>
<Toast
variant="expanded"
status="info"
progress={64}
footer="Closes in 5 seconds"
onDismiss={() => {}}
>
<Toast.Message>Import is still running</Toast.Message>
<Toast.Description>
You can keep working while the remaining files are processed in the background.
</Toast.Description>
<Toast.Action variant="secondary">View details</Toast.Action>
</Toast>
</div>
);
}Statuses
neutral is for general updates and has no icon. info reports something new from the system, success confirms a finished action, and error says what failed and offers a retry. An error toast is announced right away (role="alert"); the others wait until the screen reader is idle (role="status"). Never rely on colour alone: the message says what happened.
import { Toast } from '@/components/ui/wideset/toast/Toast';
import { type ToastStatus } from '@wideset/react';
const statuses: { status: ToastStatus; message: string; action: string }[] = [
{ status: 'neutral', message: 'Changes saved', action: 'View' },
{ status: 'info', message: 'A new version is available', action: 'Reload' },
{ status: 'success', message: 'Invoice #1042 sent', action: 'Open' },
{ status: 'error', message: 'Unable to publish changes', action: 'Retry' },
];
export default function ToastStatuses() {
return (
<div className="gap-ws-9 flex w-[25rem] max-w-full flex-col">
{statuses.map(({ status, message, action }) => (
<Toast key={status} status={status} onDismiss={() => {}}>
<Toast.Message>{message}</Toast.Message>
<Toast.Action>{action}</Toast.Action>
</Toast>
))}
</div>
);
}API reference
Toast
| Name | Description | Default |
|---|---|---|
children | Toast content, typically composed from `Toast.Message`, `Toast.Description`, and `Toast.Action`. ReactNode | — |
className | Additional CSS classes merged with the toast root element. string | — |
dismissAriaLabel | Accessible label for the dismiss button. Defaults to `'Dismiss'`. string | 'Dismiss' |
duration | Auto-dismiss duration in milliseconds. Use `0` to keep the toast visible until dismissed. number | — |
footer | Optional footer content rendered below the expanded toast body. ToastFooter | — |
onDismiss | Called when the dismiss button is pressed. (() => void) | — |
progress | Progress value from `0` to `100`. Only applies to the `expanded` variant. number | — |
progressAriaLabel | Accessible label for the progress bar. Defaults to `'Progress'`. string | 'Progress' |
status | 'success''error''info''neutral' | 'neutral' |
variant | Compact toast layout for short messages and a single inline action. Expanded toast layout with support for description, footer, and progress. 'basic''expanded' | 'basic' |
Toast.Action
| Name | Description | Default |
|---|---|---|
asChild | Whether to render the button styling onto its child element via Radix Slot. boolean | — |
children | Button label or custom content rendered inside the root. ReactNode | — |
className | Additional CSS classes merged with the button root. string | — |
defaultMotion | Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`. boolean | true |
disabled | Disables the button visually and functionally. boolean | — |
onClick | Called when the user activates the button. MouseEventHandler<HTMLButtonElement> | — |
preset | 'border''filled''ghost' | 'border' |
size | 'xs''sm''md''lg' | 'sm' |
type | Native button type used for form behavior. 'button''submit''reset' | — |
variant | 'primary''secondary''danger''success''inverse' | 'inverse' |
Toast.Container
| Name | Description | Default |
|---|---|---|
now* | Current timestamp used to derive time-based toast state. number | — |
onDismiss* | Called when a toast should be dismissed from the rendered queue. (id: string) => void | — |
position* | Screen edge where the toast stack is anchored. ToastPosition | — |
toasts* | Toasts currently rendered in the viewport. ToastItem[] | — |
defaultMotion | Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`. boolean | true |
Toast.Description
Toast.IconAction
| Name | Description | Default |
|---|---|---|
icon* | Icon rendered as the main visible content of the button. RemixiconComponentType | — |
aria-label | Defines a string value that labels the current element. Accessible action name. Provide this or `aria-labelledby`. string | — |
aria-labelledby | Identifies the element (or elements) that labels the current element. ID of the element naming the action. Provide this or `aria-label`. string | — |
asChild | Whether to render onto a child via Radix Slot. Set its accessible name on IconButton; it is forwarded to the child. boolean | — |
children | Optional child element used when `asChild` is enabled. ReactNode | — |
className | Additional CSS classes merged with the icon button root. string | — |
defaultMotion | Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`. boolean | true |
disabled | Disables the icon button visually and functionally. boolean | — |
iconClassName | Additional CSS classes merged with the rendered icon. string | — |
onClick | Called when the user activates the icon button. MouseEventHandler<HTMLButtonElement> | — |
type | Native button type used for form behavior. 'button''submit''reset' | — |
Toast.Message
| Name | Description | Default |
|---|---|---|
children* | Primary toast message content. ReactNode | — |
Toast.Provider
| Name | Description | Default |
|---|---|---|
children* | Application subtree that can render and trigger toasts. ReactNode | — |
defaultMotion | Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`. boolean | true |
position | Screen edge where the toast stack should appear. ToastPosition | 'bottom-right' |
Accessibility
errorrendersrole="alert"(announced at once); other statuses renderrole="status".- Icon actions need
aria-labeloraria-labelledbyreferencing an existing label.dismissAriaLabelandprogressAriaLabelname the dismiss button and progress bar.
| Part | Renders | Description |
|---|---|---|
| ToastRenders no element | — | A toast notification: `basic` for a short message with one inline action, `expanded` with a footer. |
| Toast.ActionRenders no element | — | An action styled for `Toast`. |
| Toast.ContainerRenders no element | — | The floating surface or stack containing feedback content. |
| Toast.DescriptionRenders no element | — | Supporting descriptive text. |
| Toast.IconActionRenders no element | — | Icon-only action rendered in the toast's top-right cluster, before the dismiss button. |
| Toast.MessageRenders no element | — | The message displayed inside the feedback surface. |
| Toast.ProviderRenders no element | — | The provider managing feedback state for its descendants. |
import { Toast } from '@/components/ui/wideset/toast/Toast';
<Toast status="success" onDismiss={() => dismiss()}>
<Toast.Message>Workspace synced</Toast.Message>
<Toast.Action>Open</Toast.Action>
</Toast>