- components
- ›
- toast
- ›
- svelte
Toast
Display brief messages to users.
Usage
This component acts as a Singleton - meaning you only implement a single instance (typically at the root scope of your app) and then reused it over and over. To do this, implement the <Toast.Group> at the root scope of your app (for SvelteKit this would be your root +layout.svelte), and use a shared createToaster() instance to trigger messages to that group from anywhere in your application.
Type
Types can be specified in one of two ways:
- Via a trigger method:
toaster.{info|success|warning|error}() - Via the object key:
type: {info|success|warning|error}
Action
Include an optional action button.
Closable
By passing closable: false you can disable the close button.
Placement
Meta
Use the meta key to provide arbitrary data. Then use this to modify your Toast template.
Promise
Use promises for asynchronous triggers.
API Reference
Root
| Property | Default | Type |
|---|---|---|
toast | - | Options<any> |
element | - | Snippet<[HTMLAttributes<"div">]> | undefinedRender the element yourself |
RootContext
| Property | Default | Type |
|---|---|---|
children | - | Snippet<[() => ToastApi<PropTypes, any>]> |
Group
| Property | Default | Type |
|---|---|---|
toaster | - | ToastStore<any> |
children | - | Snippet<[ToastProps<any>]> | undefined |
element | - | Snippet<[HTMLAttributes<"div">]> | undefinedRender the element yourself |
Message
| Property | Default | Type |
|---|---|---|
element | - | Snippet<[HTMLAttributes<"div">]> | undefinedRender the element yourself |
Title
| Property | Default | Type |
|---|---|---|
element | - | Snippet<[HTMLAttributes<"div">]> | undefinedRender the element yourself |
Description
| Property | Default | Type |
|---|---|---|
element | - | Snippet<[HTMLAttributes<"div">]> | undefinedRender the element yourself |
ActionTrigger
| Property | Default | Type |
|---|---|---|
element | - | Snippet<[HTMLAttributes<"button">]> | undefinedRender the element yourself |
CloseTrigger
| Property | Default | Type |
|---|---|---|
element | - | Snippet<[HTMLAttributes<"button">]> | undefinedRender the element yourself |