A short, prominent message, such as a confirmation, callout, or error.

Examples

Closable

Adding the closable attribute will display a close icon in the top right that hides the alert on click.

Hello there
Where's the chapstick?
<orb-alert open closable>
  <iconify-icon height="24" width="24" slot="start" icon="mdi:home"></iconify-icon>
  <h5>Hello there</h5>
  Where's the chapstick?
</orb-alert>

Progress

Set the duration attribute to have the alert close automatically after the specified amount of milliseconds. The timer will be paused if the user hovers their mouse over the alert, and will resume when the mouse leaves.

Open Alert Hello there
HTML Javascript
<orb-button id="show-progress-alert-button">Open Alert</orb-button>
<orb-alert id="progress-alert" duration="3000" class="orb-margin-top-sm">
  Hello there
</orb-alert>
const button = document.querySelector("#show-progress-alert-button");
const alert = document.querySelector("#progress-alert");
button.addEventListener("click", () => {
  alert.open = true;
});

Slots

The end slot can be used for action items like buttons

Where's the chapstick? Undo Dismiss
<orb-alert open>
  <iconify-icon height="24" width="24" slot="start" icon="mdi:settings"></iconify-icon>
  Where's the chapstick?
  <orb-button fill="outline" size="sm" slot="end">Undo</orb-button>
  <orb-button fill="outline" size="sm" slot="end">Dismiss</orb-button>
</orb-alert>

Properties

closable

Description Shows a close button that hides the alert with the userDismiss role.
Attribute closable
Type boolean
Default false

color

Description Accent color: primary, success, warning, or danger. Other values, or none, use the neutral accent.
Attribute color
Type "danger" | "primary" | "success" | "warning"
Default undefined

duration

Description Milliseconds before the alert dismisses itself with the autoDismiss role. Shows a progress bar that counts down, and pauses while the pointer is over the alert. 0 turns this off.
Attribute duration
Type number
Default 0

open

Description Shows or hides the alert, with its entrance or exit animation. Setting it to false directly dismisses with the manualDismiss role. Use hide() to pass a different role.
Attribute open
Type boolean
Default false

Events

orbDismiss

Description Emits when the exit animation finishes. The detail has the role (userDismiss, autoDismiss, manualDismiss, or the role passed to hide()) and the data passed to hide().
Type CustomEvent<T>

orbPresent

Description Emits when the entrance animation finishes.
Type CustomEvent<any>

Methods

didDismiss

Description Resolves once the alert has finished closing, with the same role and data as orbDismiss. It resolves on the next dismissal, so call it before hiding.
Signature didDismiss() => Promise<OverlayData>
Returns Promise<OverlayData> — A promise of the dismissal’s role and data

hide

Description Hides the alert. role and data are passed on to the orbDismiss event. Without a role, the event uses manualDismiss.
Signature hide(role?: string, data?: any) => Promise<void>
Parameters role (string) — - Why the alert was dismissed, such as "saved"
data (any) — - Any extra data to pass with the dismissal

show

Description Shows the alert. Same as setting open to true.
Signature show() => Promise<void>

Slots

Slot Description
The message
"end" Content after the message, such as an action button
"start" Content before the message, such as an icon

CSS Custom Properties

Name Description
--accent Accent color, set by the color prop. Colors the progress bar.
--background Background color
--border Border around the alert
--box-shadow Shadow under the alert
--color Text color

Dependencies

Depends on

Graph

graph TD; orb-alert --> orb-toolbar orb-alert --> orb-button orb-button --> orb-loading style orb-alert fill:#f9f,stroke:#333,stroke-width:4px