Component
Toast
A transient message about something that just happened.
import { Toast } from '@loidolt/theme-svelte';
Example
Notes
createToaster()owns the queue, the timers, and pause-on-hover.ToastViewportis the single live region —Toastcarries norole="status", so nothing is announced twice.actionadds one follow-up button, such as Undo. It runsonActionand then dismisses the toast unlessdismiss: false. Give an actionable toast time to be reached — at least ten seconds, orduration: 0.toaster.update(id, patch)changes a toast in place ("Uploading…" becoming "Uploaded").toaster.success/info/warning/errorare shortcuts;errorstays until dismissed unless given aduration.
Props
Generated from the component source, so it cannot drift from the implementation.
| Prop | Type | Default | Notes |
|---|---|---|---|
title required | string | — | |
action | ToastAction | — | One follow-up button, e.g. Undo. Runs onAction, then dismisses unless told not to. |
actions | Snippet | — | Custom action area, in place of action. |
children | Snippet | — | |
class | string | — | |
description | string | — | |
dismissLabel | string | 'Dismiss notification' | |
duration | number | — | Read by createToaster, not the component. Declared so {...toast} from a toaster's queue does not leak it onto the element as an attribute. |
onDismiss | () => void | — | |
ref bindable | HTMLDivElement | null | null | |
variant | StatusVariant | — |
Plus the attributes of HTMLAttributes<HTMLDivElement>, forwarded to the root element.