View as Markdown

API reference: @salmonui/notifications/toast

ToastStateinterface

import type { ToastState } from '@salmonui/notifications/toast';
interface ToastState extends ToastOptions {
    readonly id: string;
    readonly closing: boolean;
    readonly run: number;
}

A toast in the queue: its options plus store state.

ToastState members (18, 15 inherited)
NameSignatureDescription
idreadonly id: string;

Stable id returned by queue.add().

closingreadonly closing: boolean;

True during the exit transition.

runreadonly run: number;

Increments when the timer restarts (an update of duration), so the countdown bar restarts.

titleoptionalinheritedtitle?: ReactNode;

Heading line.

descriptionoptionalinheriteddescription?: ReactNode;

Body text under the title.

contentoptionalinheritedcontent?: ReactNode;

Replaces the default layout (icon, title, description, actions).

toneoptionalinheritedtone?: ToastTone;

Color role; 'danger' toasts are role="alert". Default 'neutral'.

iconoptionalinheritedicon?: ReactNode;

Replaces the built-in tone icon; false hides it. Always decorative.

durationoptionalinheritedduration?: number;

Time on screen in ms. Default 5000, or Infinity when the toast has actions; Infinity keeps it until dismissed. Counts only while visible and not paused.

dismissibleoptionalinheriteddismissible?: boolean;

Shows a close button; Escape on the focused toast also closes it. Default false.

progressoptionalinheritedprogress?: boolean;

Shows the countdown bar (a CSS animation paused with the timer).

actionsoptionalinheritedactions?: readonly ToastAction[];

Buttons in the toast.

classNameoptionalinheritedclassName?: string;

Extra class on the toast element.

styleoptionalinheritedstyle?: CSSProperties;

Inline style on the toast element, for example a width.

onOpenoptionalinheritedonOpen?: ((id: string) => void);

Called when the toast enters the visible stack.

onBeforeCloseoptionalinheritedonBeforeClose?: ((event: ToastBeforeCloseEvent) => void);

Called before the toast closes; event.preventDefault() keeps it.

onCloseoptionalinheritedonClose?: ((event: ToastCloseEvent) => void);

Called when the toast closes, with the reason.

onClickoptionalinheritedonClick?: ((event: MouseEvent<HTMLElement, MouseEvent>) => void);

Called on a click anywhere in the toast.