block

Toast

props · 37 shown · 37 total

Toaster

Appearance

  • "primary" "secondary" "tertiary"
    default "secondary"

    Default emphasis for pushed toasts when the input does not specify one. `"secondary"` is a calmer Alert variant. Per-toast overrides via `toast({ emphasis: "primary" })` are honored.

  • boolean
    default true

    Render a thin progress bar at the bottom of each toast that animates to zero across the duration.

  • boolean
    default true

    Render concurrent toasts as a deck (overlapping cards). Disable for a flat vertical list.

Layout

  • false "right" "left" "top" "bottom"
    default "right"

    Notification center layout. `"right" | "left" | "top" | "bottom"` opens it as a side drawer; `false` opens it as a centered modal dialog.

  • "top-left" "top-right" "top-center" "bottom-left" "bottom-right" "bottom-center"
    default "bottom-right"

    Default viewport corner for spawned toasts. Per-toast overrides are honored.

Behavior

  • number
    default 4000

    Default auto-dismiss duration in milliseconds. Use `Infinity` on a single toast to make it sticky.

  • boolean
    default false

    Track dismissed toasts in the history log. Required for the notification center.

  • boolean
    default true

    When `stacked` is true, fan the deck out into a vertical list on pointer/focus enter.

  • number
    default 5

    Maximum number of concurrently visible toasts. Older toasts are evicted when the limit is exceeded.

  • number
    default 50

    Maximum entries kept in the history log.

  • (history: HistoryEntry[]) => void

    Fired whenever the history array changes. Receives the full list.

  • boolean
    default true

    Pause auto-dismiss timers (and the progress bar) while the toast is hovered or focus is inside it.

  • string

    If provided AND `enableHistory` is true, the history is persisted to localStorage under this key.

  • boolean
    default true

    Enable horizontal swipe-to-dismiss via pointer events (40px threshold).

Toast

State

  • string

    Stable identifier. If omitted, an id is hashed from title + content. Reusing an id triggers dedupe (the existing toast updates in place).

  • boolean
    default true

    Initial unread state when pushed to the history log.

Appearance

  • string HTMLElement ToastContentRenderer

    Body text, an `HTMLElement`, or a render function `(container) => void`. The Svelte block accepts a string only inside the Toaster row template; use `toast.custom` for arbitrary content.

  • "primary" "secondary" "tertiary"

    Visual emphasis. `"secondary"` (default) is a subtler, less attention-grabbing Alert variant — recommended for everyday tone. `"primary"` is the loud filled variant — reserve for critical / can't-miss messages.

  • string HTMLElement

    Custom icon — an `HTMLElement` or an icon name string. Defaults to the icon for the toast `type`.

  • string

    Heading text. When omitted the toast renders in a compact row layout (icon + content + close).

  • "primary" "success" "danger" "warning" "neutral" "loading"
    default "neutral"

    Visual tone. `"loading"` defaults to a sticky duration.

Layout

  • "top-left" "top-right" "top-center" "bottom-left" "bottom-right" "bottom-center"

    Override the toaster's default viewport corner for this toast.

Behavior

  • ToastAction

    Render an action button inline with the dismiss control. `onClick` fires when pressed.

  • string

    Render inside the element with this id instead of the global viewport — useful for scoped toasters inside dialogs.

  • number

    Override the toaster's default duration for this toast (ms). Use `Infinity` for a sticky toast.

  • () => void

    Fired only when the toast is removed by the auto-dismiss timer.

  • () => void

    Fired when the toast is removed from the screen (manual dismiss OR auto-close).

  • boolean
    default true

    When `toast.update()` patches an existing toast, whether to restart the timer from zero. Use `false` for purely visual updates that shouldn't extend lifetime.

  • boolean string
    default false

    Play a short audio cue. `true` plays a built-in WebAudio blip per type; a string is treated as an audio URL.

Advanced

  • boolean

    When true, render as a custom (non-Alert) toast row. Internal, set by `toast.custom()`.

ToastHistory

State

  • history required
    HistoryEntry[]

    Read-only array of history entries, newest first.

  • isCenterOpen required
    boolean

    Whether the built-in notification dialog is currently open.

  • unreadCount required
    number

    Number of entries with `unread: true`.

Behavior

  • clearHistory required
    () => void

    Empty the history log.

  • markAllAsRead required
    () => void

    Mark every history entry as read.

  • markAsRead required
    (id: string) => void

    Mark a single history entry as read by id.

  • toggleCenter required
    (force?: boolean) => void

    Open or close the built-in notification dialog. Pass `true`/`false` to force a state.

Type

  • Components
  • Blocks