Skip to content

Alert

Class: FxAlert · Tag: <fx-alert>

<fx-alert> is an inline banner for alarms and notices. Use variants for the look, optional icons, and optional dismiss. Stacked toasts use the same control via Toaster.


import '@salsafx/ui';
<fx-alert variant="danger" text="Gearbox oil temp high"></fx-alert>
<fx-alert variant="warning" text="Nacelle vibration warning"></fx-alert>
<fx-alert variant="success" text="Generator online"></fx-alert>
<fx-alert variant="info" text="Pitch calibration in progress"></fx-alert>

<fx-alert variant="primary" text="Primary"></fx-alert>
<fx-alert variant="danger" text="Danger"></fx-alert>

Long copy wraps inside the banner. The icon stays vertically centered on the whole text block.

<fx-alert
variant="info"
text="Pitch calibration in progress. Check hydraulic pressure, yaw encoder offset, and generator temperature before continuing."
></fx-alert>

Omit the icon with has-icon="false". Override the default variant icon with icon.

<fx-alert variant="danger" has-icon="false" text="Without icon"></fx-alert>
<fx-alert variant="warning" icon="fa-solid fa-wind" text="Wind speed approaching cut-out"></fx-alert>

Set dismissible to show a close control. Listen for dismiss to remove or hide the alert.

<fx-alert id="notice" variant="warning" dismissible text="Sticky notice"></fx-alert>
<script>
document.getElementById('notice').addEventListener('dismiss', (event) => {
event.target.remove();
});
</script>

PropertyAttributeTypeDefaultDescription
variantvariantString"info"Semantic look. See Variants.
iconiconString""Icon-font class list. Empty uses the variant default.
hasIconhas-iconBooleantrueShows the leading icon. Use has-icon="false" to hide it.
hasShadowhas-shadowBooleanfalseDrop shadow. Off by default on standalone alerts; toasts turn it on.
texttextString""Banner copy. Line breaks in the string are kept.
sizesizeString"large""small", "medium", or "large".
dismissibledismissibleBooleanfalseShows a close control.
NameDescription
— (default)Banner copy when text is not set.
iconCustom leading icon markup.
NameDescription
dismissFired when the close control is used.

classDiagram
    direction TB
    class FxElement
    class FxAlert
    FxElement <|-- FxAlert

See also Architecture and Toaster.