ot.toast(message, title?, options?). Toasts appear temporarily to provide feedback without interrupting the user’s workflow.
Basic Usage
JavaScript API
Basic Method
message(string) - The toast message contenttitle(string, optional) - The toast titleoptions(object, optional) - Configuration options
Options
| Option | Type | Default | Description |
|---|---|---|---|
variant | string | '' | 'success', 'danger', or 'warning' |
placement | string | 'top-right' | Position on screen (see placements below) |
duration | number | 4000 | Auto-dismiss time in milliseconds (0 = never) |
Placement
Toasts can be positioned in 6 different locations:Toasts stack vertically at each placement. Bottom placements show newest toasts at the bottom.
Custom HTML Content
Useot.toast.el(element, options?) to show toasts with custom HTML content.
From a Template
Dynamic Element
The element is cloned before display, so templates can be reused multiple times.
Clearing Toasts
Clear all toasts or toasts at a specific placement:Variants
Success
Green accent color for successful operations:Danger
Red accent color for errors:Warning
Yellow/orange accent color for warnings:Styling
Toasts include:- Card-style background with subtle shadow
- Color-coded left border based on variant
- Smooth enter/exit animations
- Responsive max-width (28rem) and min-width (20rem)
- Auto-stacking with proper spacing
Accessibility
Toasts userole="status" or role="alert" for screen reader announcements. The close button includes proper ARIA attributes for keyboard navigation.
For full API documentation including advanced usage and events, see the Toast API reference.