Toast
A notification that briefly shows a task result and closes automatically.
Usage guide
#Use for brief feedback that does not interrupt work, such as successful saving. Use Modal when a response is required.
Create a notification
Create notifications with
createToast()or status-specific methods. They stack at the specified position in the document body.Set the duration
durationis in milliseconds. 0 disables automatic dismissal. Provideclosablefor persistent notifications.Dismiss to match the workflow
Use
closeToast()when the app's workflow requires dismissal.
Examples
#Feature examples
#Choose a feature from 18 topics. Explore property settings, method calls, event results, and slot layouts through live examples and code.
No matching features.
API reference
#Hover over a name or focus it with the keyboard to see the code. On touch screens, tap the name.
<sy-toast>
Properties
| Attribute / Property | Type | Default | Description |
|---|---|---|---|
boolean | false | Show new notifications first at the same position. | |
number | 3000 | Time before automatic dismissal, in milliseconds. Set to 0 to keep it open. | |
HTMLSyToastItemElement['animation'] | 'none' | Default enter/exit animation for spawned toasts. Per-call `option.animation`
overrides this. Pass objects and arrays as JavaScript properties. | |
HTMLSyToastItemElement['animationSpeed'] | 'fast' | Default animation speed for spawned toasts. Per-call `option.animationSpeed`
overrides this. Pass objects and arrays as JavaScript properties. |
Methods
| Method | Returns | Description |
|---|---|---|
Promise<HTMLSyToastItemElement> | Create a notification with the specified status and options. | |
Promise<HTMLSyToastItemElement> | Create a neutral notification. | |
Promise<HTMLSyToastItemElement> | Create a success notification. | |
Promise<HTMLSyToastItemElement> | Create an error notification. | |
Promise<HTMLSyToastItemElement> | Create an informational notification. | |
Promise<HTMLSyToastItemElement> | Create a warning notification. | |
Promise<void> | Close the supplied sy-toast-item element. |
Slots
| Slot | Description |
|---|---|
| Content displayed in the icon area. | |
| Content displayed in the header area. | |
| Content displayed in the body area. | |
| Content displayed in the footer area. |
<sy-toast-item>
Properties
| Attribute / Property | Type | Default | Description |
|---|---|---|---|
boolean | false | Whether the notification is visible. Control it with the show and close methods. | |
'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'bottomRight' | Item layout direction. | |
'neutral' | 'success' | 'error' | 'info' | 'warning' | 'neutral' | Component display style. | |
boolean | false | Show the close button. | |
number | undefined | Time before automatic dismissal, in milliseconds. Set to 0 to keep it open. | |
boolean | false | Show new notifications first at the same position. | |
| 'none'
| 'fade' | 'fade-scale' | 'zoom' | 'pop'
| 'slide-top' | 'slide-bottom' | 'slide-left' | 'slide-right'
| 'slide-fade-top' | 'slide-fade-bottom' | 'slide-fade-left' | 'slide-fade-right'
| 'reveal-top' | 'reveal-bottom' | 'reveal-left' | 'reveal-right'
| 'flip-x' | 'flip-y' | 'bounce' | 'spin' | 'none' | Enter/exit animation type. `none` (default) toggles instantly. | |
'x-fast' | 'fast' | 'medium' | 'slow' | 'x-slow' | 'fast' | Animation playback speed token. Maps to `--transition-*` global tokens. |
Methods
| Method | Returns | Description |
|---|---|---|
Promise<void> | Show the notification. | |
Promise<void> | Close the open panel. |
Slots
| Slot | Description |
|---|---|
| Content displayed in the icon area. | |
| Content displayed in the header area. | |
| Content displayed in the body area. | |
| Content displayed in the footer area. |