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().
| Name | Signature | Description |
|---|---|---|
titleoptional | title?: ReactNode; | Heading line. |
descriptionoptional | description?: ReactNode; | Body text under the title. |
contentoptional | content?: ReactNode; | Replaces the default layout (icon, title, description, actions). |
toneoptional | tone?: ToastTone | undefined; | Color role; |
iconoptional | icon?: ReactNode | false; | Replaces the built-in tone icon; |
durationoptional | duration?: number | undefined; | Time on screen in ms. Default 5000, or |
dismissibleoptional | dismissible?: boolean | undefined; | Shows a close button; Escape on the focused toast also closes it. Default |
progressoptional | progress?: boolean | undefined; | Shows the countdown bar (a CSS animation paused with the timer). |
actionsoptional | actions?: readonly ToastAction[] | undefined; | Buttons in the toast. |
classNameoptional | className?: string | undefined; | Extra class on the toast element. |
styleoptional | style?: CSSProperties | undefined; | Inline style on the toast element, for example a width. |
onOpenoptional | onOpen?: ((id: string) => void) | undefined; | Called when the toast enters the visible stack. |
onBeforeCloseoptional | onBeforeClose?: ((event: ToastBeforeCloseEvent) => void) | undefined; | Called before the toast closes; |
onCloseoptional | onClose?: ((event: ToastCloseEvent) => void) | undefined; | Called when the toast closes, with the reason. |
onClickoptional | onClick?: ((event: MouseEvent<HTMLElement>) => void) | undefined; | Called on a click anywhere in the toast. |