Import
Basic Usage
Variants
- Preview
- Code
Five alert variants:
- info - Blue, informational
- success - Green, positive outcome
- warning - Yellow, caution
- danger - Red, error or critical
- neutral - Gray, general message
Shorthand Functions
With Title
Icons
Alerts show an icon by default. Customize or hide it:Dismissible Alerts
Add a close button:With Actions
Add buttons to the alert:Toast Notifications
Toasts are floating alerts that appear temporarily:Toast Positions
top-right(default)top-lefttop-centerbottom-rightbottom-leftbottom-center
Toast Container
For multiple toasts, create a container:Complex Example
Use in Tool Templates
API Reference
alert(message, options?)
| Parameter | Type | Description |
|---|---|---|
message | string | Alert message text |
options | AlertOptions | Configuration options |
AlertOptions
| Option | Type | Default | Description |
|---|---|---|---|
variant | 'info' | 'success' | 'warning' | 'danger' | 'neutral' | 'info' | Visual style |
title | string | - | Alert heading |
showIcon | boolean | true | Show variant icon |
icon | string | - | Custom icon HTML |
dismissible | boolean | false | Show close button |
className | string | - | Additional CSS classes |
id | string | - | Alert ID |
actions | string | - | HTML for action buttons |
onDismiss | object | - | HTMX options for dismiss |
toast(message, options?)
| Option | Type | Default | Description |
|---|---|---|---|
variant | AlertVariant | 'info' | Visual style |
title | string | - | Toast heading |
duration | number | 5000 | Auto-dismiss ms (0 = no auto) |
position | string | 'top-right' | Screen position |
id | string | auto-generated | Toast ID |
Returns
string - HTML string for the alert/toast element.
