BwToast | bw-toast
Overview
Toast are overlays that display a message to the user.
Usage
Basic
- Typescript
- HTML
document.querySelector('#toastButton')?.addEventListener('click', () => {
document.querySelector("#toast")!.open = true
})
<bw-button id="toastButton">Show Card Toast</bw-button>
<bw-toast id="toast" duration="6000" progress header="Hello there!" message="This is a toast..." variant="card" type="success" position="bottom-start">
<bw-button slot="buttons" size="sm" variant="link">Ok</bw-button>
<bw-button slot="buttons" size="sm" variant="link" color="gray">Cancel</bw-button>
</bw-toast>
- Typescript
- HTML
import { createToast } from 'bluewater';
document.querySelector('#toastButton')?.addEventListener('click', () => {
const toast = createToast({
header: 'Hello',
message: 'This is a bar toast',
variant: 'bar',
position: "top-end"
})
toast.open = true
})
<bw-button id="toastButton">Try clicking me multiple times!</bw-button>
Properties
| Property | Attribute | Description | Type | Default |
|---|---|---|---|---|
duration | duration | The duration of the toast | number | 3000 |
header | header | The header of the toast | string | undefined |
message | message | The message of the toast | string | undefined |
open | open | Whether the toast is open | boolean | false |
type | type | The type of toast to display | "error" | "informational" | "instructional" | "success" | "warning" | 'informational' |
variant | variant | The variant of the toast | "bar" | "card" | 'card' |
Events
| Event | Description | Type |
|---|---|---|
ready | Emitted when the component has completed it's first render | CustomEvent<any> |
toastDismiss | Emitted when the toast is dismissed | CustomEvent<{ role?: string; data?: any; }> |
toastPresent | Emitted when the toast is presented | CustomEvent<any> |
Methods
didDismiss() => Promise<OverlayData>
Returns a promise that resolves when the toast is dismissed
Returns
Type: Promise<OverlayData>
The data of the dismiss
dismiss(role?: string, data?: any) => Promise<void>
Dismisses the toast
Parameters
| Name | Type | Description |
|---|---|---|
role | string | - The role of the dismiss |
data | any | - The data of the dismiss |
Returns
Type: Promise<void>
present() => Promise<void>
Presents the toast
Returns
Type: Promise<void>
Slots
| Slot | Description |
|---|---|
"buttons" | Buttons go here |
"content" | Header and message |
Shadow Parts
| Part | Description |
|---|---|
"message" | The message of the toast |
"progress" |
CSS Custom Properties
| Name | Description |
|---|---|
--background | The background color of the toast |
--color | The color of the toast |
Dependencies
Depends on
Graph
© 2025 United Systems & Software - All Rights Reserved.