Alert
Alerts surface important, page-level information that needs attention without blocking the user.
Components · Messaging
An alert is a bordered, page-level banner that surfaces information the user should notice but isn't required to act on immediately. Namirial alerts are built from --nm-alert-* tokens defined in namirial-theme.css, ship at a single fixed size, and default to the info intent when no modifier is applied.
Overview
An alert lives inline in the page layout — above a form, at the top of a section — and stays visible until the underlying condition changes or the user dismisses it. It never floats above content and never disappears on its own.
When to use
Use an alert when:
- The information applies to the whole page or section, not a single field (system status, an expired session, a pending review).
- The message should persist until the user deals with it or navigates away — not vanish after a few seconds.
Consider another component when:
- The feedback is tied to a single field's value — use the input's own error/warning/success state instead.
- The message is a one-off confirmation of an action the user just took and can safely disappear on its own — use Toast.
- The message needs to interrupt the user and block further action until resolved — use a Dialog.
Anatomy
An alert is a single-row container with a leading icon, a text body, and an optional close button — three parts sharing one set of intent tokens.
Tokens and values that drive each part
| Part | Role | Source |
|---|---|---|
| Container | Fill | --nm-alert-bg |
| Container | Border | --nm-alert-border |
| Container | Radius / padding / gap | border-radius: 8px · padding: 8px 12px · gap: 16px |
| Icon | Color | --nm-alert-fg |
| Body text | Color | --nm-alert-fg |
| Link (inline) | Color / weight | --nm-alert-fg (inherited), font-weight: 600, underlined |
| Close button | Color | --nm-alert-fg, opacity: 0.7 hover / 0.5 active |
Intent variants
An alert ships seven intents. With no modifier class, .nm-alert renders as info — the same as adding nm-alert--info explicitly.
Content types
With a link
.nm-alert__link inherits the alert's text color and only adds weight and underline — it never introduces a separate link color, so it stays legible against every intent.
Dismissible
Add .nm-alert__close as a real <button> when the condition is safe for the user to acknowledge and hide. Don't add a close button when the alert reflects a state the user still needs to resolve.
Light & dark theme
Alert tokens read from the shared --palette-callout-* scale, so no per-component dark override is needed — the palette layer already remaps under data-theme="dark".
Both previews are locked — they don't follow the page theme switcher.
Do & don't
Accessibility
Semantics
- Give the alert container
role="status"for informational intents, orrole="alert"fornegative/warningso assistive tech announces it immediately. - The icon is decorative and duplicates the intent already carried by color and text — mark it
aria-hidden="true".
Dismissal
- The close button must be a real
<button>witharia-label="Dismiss"(or similarly explicit) — never a bare icon with a click handler. - Removing an alert from the DOM on dismiss is enough; no focus management is required unless the alert was the page's only interactive landmark.
Color
- Never rely on the border/background color alone to communicate severity — the icon and text must independently make the intent clear.
Token reference
| Token | Role |
|---|---|
| --nm-alert-bg | Container fill — recolored per intent |
| --nm-alert-border | Container border — recolored per intent |
| --nm-alert-fg | Icon, body text, and link color — recolored per intent |
Implementation
No JavaScript is required for a static alert — it's a styled <div> with a text body, only the optional close button needs a click handler.
<link rel="stylesheet" href="namirial-theme.css">
<div class="nm-alert nm-alert--warning" role="alert">
<span class="nm-alert__icon" aria-hidden="true"><!-- icon --></span>
<span class="nm-alert__body">Your trial ends in 3 days.</span>
<button type="button" class="nm-alert__close" aria-label="Dismiss"><!-- x icon --></button>
</div>CSS classes
| Class | Values | Default |
|---|---|---|
nm-alert--{intent} | primary · secondary · accent · info · positive · negative · warning — omit for info | — (info) |
nm-alert__icon | Leading icon slot, 24×24px | — |
nm-alert__link | Inline emphasized link inside the body | — |
nm-alert__close | Dismiss button, 24×24px, must be a <button> | — |