Toast

Toast surfaces brief, non-blocking feedback about the result of a user action or system event.

Workspace synced
tsx
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.

tsx
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.

tsx
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

NameDescriptionDefault
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

NameDescriptionDefault
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

NameDescriptionDefault
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

No props of its ownIt takes its content as children and nothing else.

Toast.IconAction

NameDescriptionDefault
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

NameDescriptionDefault
children*

Primary toast message content.

ReactNode
—

Toast.Provider

NameDescriptionDefault
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

  • error renders role="alert" (announced at once); other statuses render role="status".
  • Icon actions need aria-label or aria-labelledby referencing an existing label. dismissAriaLabel and progressAriaLabel name the dismiss button and progress bar.
PartRendersDescription
Toast—A toast notification: `basic` for a short message with one inline action, `expanded` with a footer.
Toast.Action—An action styled for `Toast`.
Toast.Container—The floating surface or stack containing feedback content.
Toast.Description—Supporting descriptive text.
Toast.IconAction—Icon-only action rendered in the toast's top-right cluster, before the dismiss button.
Toast.Message—The message displayed inside the feedback surface.
Toast.Provider—The provider managing feedback state for its descendants.
Workspace synced
tsx
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>

Appearance

Variant
Status

Content

Action
Dismiss button