On this Page
ToastOptions
ToastOptions configures one notification created with toast. It is a TypeScript interface, not a rendered component.
Usage
TypeScript
import { toast, type ToastOptions } from "fractalsvelte";
const options: ToastOptions = {
description: "Your profile is now public.",
duration: 4000,
tone: "success",
};
toast("Profile updated", options);
Pass the options object as the second argument to toast, or to a semantic helper such as toast.success.
API
| Field | Type | Default | Description |
|---|---|---|---|
description | string | undefined | Optional supporting detail displayed below the toast message. |
duration | number | 5000 | Auto-dismiss delay in milliseconds. Use 0 to keep the toast open until it is dismissed. |
tone | ToastTone | 'neutral' | Visual and semantic emphasis for the notification. |
The toast(message, options?) function returns the numeric toast id. Pass that id to toast.dismiss(id) to remove one notification, or call toast.dismiss() to clear the queue.
Related
Use ToastTone to constrain the tone field, and mount Toaster once near the application root to display the queue.
