View as Markdown

API reference: @salmonui/notifications/toast

ToastOptionsinterface

import type { ToastOptions } from '@salmonui/notifications/toast';
interface ToastOptions {
    title?: ReactNode;
    description?: ReactNode;
    content?: ReactNode;
    tone?: ToastTone | undefined;
    icon?: ReactNode | false;
    duration?: number | undefined;
    dismissible?: boolean | undefined;
    progress?: boolean | undefined;
    actions?: readonly ToastAction[] | undefined;
    className?: string | undefined;
    style?: CSSProperties | undefined;
    onOpen?: ((id: string) => void) | undefined;
    onBeforeClose?: ((event: ToastBeforeCloseEvent) => void) | undefined;
    onClose?: ((event: ToastCloseEvent) => void) | undefined;
    onClick?: ((event: MouseEvent<HTMLElement>) => void) | undefined;
}

The object passed to queue.add() and queue.update().

ToastOptions members (15)
NameSignatureDescription
titleoptionaltitle?: ReactNode;

Heading line.

descriptionoptionaldescription?: ReactNode;

Body text under the title.

contentoptionalcontent?: ReactNode;

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

toneoptionaltone?: ToastTone | undefined;

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

iconoptionalicon?: ReactNode | false;

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

durationoptionalduration?: number | undefined;

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.

dismissibleoptionaldismissible?: boolean | undefined;

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

progressoptionalprogress?: boolean | undefined;

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

actionsoptionalactions?: readonly ToastAction[] | undefined;

Buttons in the toast.

classNameoptionalclassName?: string | undefined;

Extra class on the toast element.

styleoptionalstyle?: CSSProperties | undefined;

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

onOpenoptionalonOpen?: ((id: string) => void) | undefined;

Called when the toast enters the visible stack.

onBeforeCloseoptionalonBeforeClose?: ((event: ToastBeforeCloseEvent) => void) | undefined;

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

onCloseoptionalonClose?: ((event: ToastCloseEvent) => void) | undefined;

Called when the toast closes, with the reason.

onClickoptionalonClick?: ((event: MouseEvent<HTMLElement>) => void) | undefined;

Called on a click anywhere in the toast.