Messaging

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.

Your session will expire in 5 minutes.
Signing failed. Please try again.

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

PartRoleSource
ContainerFill--nm-alert-bg
ContainerBorder--nm-alert-border
ContainerRadius / padding / gapborder-radius: 8px · padding: 8px 12px · gap: 16px
IconColor--nm-alert-fg
Body textColor--nm-alert-fg
Link (inline)Color / weight--nm-alert-fg (inherited), font-weight: 600, underlined
Close buttonColor--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.

Primary — general product messaging.
Secondary — lower-emphasis note.
Accent — highlight a new feature.
Info — neutral, default intent.
Positive — confirms a successful state.
Warning — needs attention soon.
Negative — something failed or is blocked.

Content types

.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.

Your card expires soon. Update payment method.

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.

We've updated our terms of service.

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".

Light data-theme="light"
Signing failed. Try again.
Dark data-theme="dark"
Signing failed. Try again.

Both previews are locked — they don't follow the page theme switcher.

Do & don't

✓Do
Your trial ends in 3 days.
Match the intent to the message — warning for something needing attention soon.
✕Don't
Your trial ends in 3 days.
Don't reach for the most severe intent by default — reserve negative for actual failures.
✓Do
Payment failed. Update your card to continue.
Say what happened and what to do next.
✕Don't
Something went wrong.
Don't leave the user without a next step.

Accessibility

Semantics

  • Give the alert container role="status" for informational intents, or role="alert" for negative/warning so 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> with aria-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

TokenRole
--nm-alert-bgContainer fill — recolored per intent
--nm-alert-borderContainer border — recolored per intent
--nm-alert-fgIcon, 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

ClassValuesDefault
nm-alert--{intent}primary · secondary · accent · info · positive · negative · warning — omit for info— (info)
nm-alert__iconLeading icon slot, 24×24px—
nm-alert__linkInline emphasized link inside the body—
nm-alert__closeDismiss button, 24×24px, must be a <button>—