Alert

Alert

HkAlert is the static message strip: one glyph, an optional bold heading and a line of body copy, painted in the ink of one of four semantic variants. It lives in the flow of a page, a card or a form — it does not float, does not expire and does not take focus.

  • Anything that appears on its own, slides in from a corner and goes away by itself is a transient notification, not an alert.
  • An action that needs a decision before the page may continue belongs in a HkConfirmDialog or a HkModal, not in a message strip.

Import

tsx
1
import { HkAlert, type AlertVariant, type AlertSize } from "@celestia-island/hikari";
rust
1
2
use hikari_components::*;          // Alert, AlertVariant, AlertSize
use hikari_components::prelude::*; // rsx!, VNode, Icon, MdiIcon

Variants

variant is the ink and the announcement tone at once: error (the default), warning, info and success. Each variant also picks its glyph — a triangle for error and warning, an information mark for info, a tick for success — so a message reads correctly even before the colour is registered.

Nightly backups run at 02:00 UTC.

Your changes have been saved.

Title, sizes and banner

title adds a bold heading above the body. size steps the type from sm through md (default) to lg, and banner turns the strip into the full-width presentation that sits flush under a page header. padding overrides the box's own spacing with one of the shared container steps — none, xs, sm, md, lg — written to the same --hk-pad custom property every container consumes, so one stylesheet serves both renderers. The Rust example below shows the size step only: the padding field exists on the mirror (Option<HkPad>), but the HkPad type is not reachable through the documented use hikari_components::* plus prelude imports, so the example cannot spell it — a re-export gap worth fixing upstream, not in these pages.

Compact step

Dismissal and custom content

With closable the strip carries a ✕ on its trailing edge, which emits close. Vue dismisses the instance itself on press — there is no v-model, so showing it again means remounting it at the call site. The Rust mirror has no local state to hide behind: it keeps rendering while visible is true, fires on_close, and the host flips visible (or unmounts the alert) — that is the shape the second stage below shows.

The icon slot (Rust: the icon element prop) replaces the variant's glyph, and the default slot (Rust: body) replaces the message text.

A new version is available.

Import finished

312 rows added, 4 skipped.

Accessibility

  • The root carries a live region unless you opt out: error and warning publish role="alert" with aria-live="assertive", info and success publish role="status" with aria-live="polite". Because the whole strip is one region, the heading and the body are announced together.
  • A live region only announces content inserted or changed after it registers; an alert already present at mount is read in document order like static text. Mount the alert when the condition appears, which is also how the in-repo consumers use it.
  • ownsLiveRegion={false} drops the role / aria-live pair while keeping the visuals — for an alert nested inside a container that already owns the region. Without the opt-out a nested alert would announce twice.
  • Never rely on colour alone: the variant glyph carries the same meaning as the ink.
  • The ✕ is a standard icon button with an accessible name (hikari::alert.close, falling back to "Close"), and it is the only focusable part of the strip.

API

Vue

Props

NameTypeDefaultRequired
variantString as PropType<AlertVariant>"error"—
messageString—✓
titleStringundefined—
closableBooleanfalse—
bannerBooleanfalse—
sizeString as PropType<AlertSize>"md"—
paddingString as PropType<HkPad>undefined—
ownsLiveRegionBooleantrue—

Emits

EventPayload
close—

Rust

Props — Alert

PropTypeDefaultDescription
variantAlertVariantAlertVariant::ErrorSemantic variant; also picks the default icon and the ink color.
messageString""Body text (Vue: message, required).
titleOption<String>NoneOptional bold heading above the body (hk-alert-title).
closableboolfalseRender the ✕ button; clicking hides this instance and fires AlertProps::on_close.
bannerboolfalseFull-width banner presentation (hk-alert-banner).
sizeAlertSizeAlertSize::MdSize step (hk-alert-{size}).
paddingOption<HkPad>NoneShared container-padding override (--hk-pad; see utils::pad).
owns_live_regionbooltrueMirror of the Vue ownsLiveRegion prop (default true): false drops the root's role/aria-live pair while keeping the visuals, for an alert nested inside a container that already owns the live region (the failed HkAuthHandoff card).
iconOption<Element>NoneIcon slot: replaces the per-variant default icon.
bodyOption<Element>NoneBody slot (Vue: the default slot).
visiblebooltrueKeep rendering the alert (Vue: the uncontrolled local dismissal flag; see the file-header delta — the host owns this on the Rust side).
on_closeOption<EventHandler<MouseEvent>>NoneFired when the ✕ button is clicked; the host flips visible.
classString""—

Related components

  • HkSpinner — an inline busy indicator, without a message.
  • HkEmptyState — the placeholder for a region that has no content yet, including its loading variant.
  • HkLoadingVeil — the blocking overlay for a navigation-span wait.
  • Button — the text action an alert often points at.
  • HkConfirmDialog — asking before an irreversible step.