Inline Alert

An inline contextual message that communicates status, confirmation, warning, or error within the content flow without blocking the page.

An Inline Alert places a short, contextual message next to the content it relates to. Use it for status, confirmation, warnings, and errors that do not need to interrupt the user. For transient or stacked system messages, use a toast or notification pattern instead; for blocking confirmation, use Dialog.

Anatomy

1 2 3
  1. 1 Icon — a decorative indicator chosen from the variant; provides a second cue alongside color.
  2. 2 Content — a title and an optional description.
  3. 3 Dismiss button — optional; hides the alert when activated.

Options

Variants

Default
Info
Positive
Negative
Notice

Variants select an appearance and a default icon; they do not infer meaning from the text. Choose the variant and wording together.

Sizes

Medium · default
Small

Container scaling

Use the Scale switch beside Light/Dark in the preview above, or set data-scale="small|medium|large" on a containing element. Font size, line height, spacing and corner radius inherit that context. A local size="sm" remains smaller within the chosen context; it does not cancel the container scale. Border width stays fixed.

Container small
Container medium
Container large

The default context is medium. A nested container replaces the inherited context explicitly, without multiplying the parent context again. Brand and light/dark mode remain independent.

Table of options

Custom ElementNunjucksValues and defaults
variantvariantEmpty default (neutral), info, positive, negative, notice. Unsupported values fall back to the neutral default.
titletitleBold heading text. Optional; omitted when empty.
descriptiondescriptionBody text. Optional; omitted when empty.
iconiconIcon name override. Defaults to a variant-appropriate icon; the neutral default has no icon unless set.
sizesizemd (default) or sm. Relative to the inherited container scale.
dismissibledismissiblefalse (default) or present/true. Adds a dismiss button.

Behaviors

Dismiss

When dismissible is set, a close button appears. Activating it adds the is-hidden class and the Custom Element dispatches a uif-dismiss event. Dismissal does not remove the element from the DOM.

Title-only

The description is optional. When omitted, the title occupies the content area on its own.

Usage guidelines

Do

Use positive for confirmed actions and successful outcomes, with wording that matches.

Don't

Do not pair a success message with the negative variant — it signals an error and misleads.

Place the alert next to the content it concerns. Keep a single clear message per alert and avoid stacking many alerts in one region.

Content standards

  • Keep titles short, around 3–7 words, in sentence case.
  • Write descriptions in plain language; make them concise and actionable.
  • Do not repeat the title content in the description.
  • Provide localized text. The component does not translate content.

Keyboard interactions

Key Action
Tab Moves focus to the dismiss button, when present.
Enter / Space Activates the focused dismiss button.

Without a dismiss button the alert has no interactive controls and does not enter the tab order.

Accessibility

  • The container uses role="alert" so assistive technologies announce the message when it is inserted.
  • Icons are decorative and carry aria-hidden="true".
  • The dismiss button has an explicit aria-label="Dismiss" and a visible focus indicator.
  • Color is not the only cue: the variant icon and the wording carry the meaning (WCAG 1.4.1).
  • Rapidly inserting or updating alerts can cause repeated announcements; insert them deliberately.

Implementation

Import the individual module once, or use the aggregate ui-foundations/elements entry.


import "ui-foundations/elements/ui-inline-alert";


<uif-inline-alert variant="info" title="Information" description="Here is some helpful context."></uif-inline-alert>
<uif-inline-alert variant="negative" title="Error" description="Something went wrong." dismissible></uif-inline-alert>

For static HTML without Custom Element JavaScript, use the macro:


{% import "macros/ui.njk" as uif %}
{{ uif.inlineAlert(title="Information", description="Here is some helpful context.", variant="info", dismissible=true) }}

The macro and Custom Element emit the same markup: a .uif-inline-alert container with .uif-inline-alert-icon, .uif-inline-alert-content (.uif-inline-alert-title and .uif-inline-alert-description) and an optional .uif-inline-alert-dismiss button. Title and description text are escaped.

The scale belongs to the container, not to the size attribute:


<div data-scale="large">
  <uif-inline-alert size="sm" variant="info" title="Information"></uif-inline-alert>
</div>

Theming

Use the brand and mode switches in the preview above. Visual values come from the pattern's --uif-inline-alert-* slots, which alias existing Semantic roles: surfaces, borders and content colors per variant. Set data-brand="a", "b" or "c" and data-mode="light" or "dark" on the root element. Consumers own activation of these contexts. See Design Tokens.

Tokens

Token
--_uif-context-scale
--_uif-local-scale
--_uif-scale-small
--uif-inline-alert-border-radius
--uif-inline-alert-border-size
--uif-inline-alert-content-gap
--uif-inline-alert-default-border-color
--uif-inline-alert-default-container-background
--uif-inline-alert-default-text-color
--uif-inline-alert-font-family
--uif-inline-alert-font-size
--uif-inline-alert-gap
--uif-inline-alert-info-border-color
--uif-inline-alert-info-container-background
--uif-inline-alert-info-text-color
--uif-inline-alert-line-height
--uif-inline-alert-negative-border-color
--uif-inline-alert-negative-container-background
--uif-inline-alert-negative-text-color
--uif-inline-alert-notice-border-color
--uif-inline-alert-notice-container-background
--uif-inline-alert-notice-text-color
--uif-inline-alert-padding-block
--uif-inline-alert-padding-inline
--uif-inline-alert-positive-border-color
--uif-inline-alert-positive-container-background
--uif-inline-alert-positive-text-color
--uif-inline-alert-title-font-weight
--uif-semantic-color-focus
--uif-semantic-size-border-default
--uif-semantic-size-border-thick

Design checklist

✓
Runtime and examplesCSS, Custom Element, static macro and playground are implemented.
✓
Accessible use of color and rolerole="alert", decorative icons as a second cue, and labelled dismiss control.
○
Figma parity and Code ConnectLive source access is unavailable. Design parity is unverified and the mapping example is inactive.
○
Playground code tabs (Nunjucks / Web Component)The HTML tab and live preview work. The Nunjucks and Web Component tabs are not yet wired to a code generator.

Automated checks cover markup, token resolution and naming. They do not certify complete accessibility or live design parity.

Optional action

Use action-label / actionLabel to add one recovery action inside the content region. It renders as a button, or as a link when action-href / actionHref is provided. Allowed URL prefixes are http:, https:, mailto:, tel:, / and #; unsupported URLs fall back to #. Action text is escaped.

<uif-inline-alert variant="negative" title="Could not save" action-label="Try again"></uif-inline-alert>
{{ uif.inlineAlert(title="Session expired", actionLabel="Sign in", actionHref="/login") }}