Skip to main content

Alert

Info:Feedback html svelte astro Success: coverage 106/106

An inline message banner with an optional severity glyph, a title, actions, and a dismissible form — color and meaning on independent axes.

Live demo

live · @xoji/astro

Alert

The four tones, soft

Info notice
A status-toned banner. Same anatomy, different semantic weight — danger and warn announce assertively, info and success politely.
Success notice
A status-toned banner. Same anatomy, different semantic weight — danger and warn announce assertively, info and success politely.

Solid variant

Info
The solid treatment fills the surface for higher-priority moments.
Success
The solid treatment fills the surface for higher-priority moments.

With actions & dismiss

Theme published
Your algorithm is live in the marketplace. This banner is dismissible — close it.
A bare, dismissible info note with no title. Click the × to retire it.

Every tone

The four status tones (success, info, warn, danger) carry a severity icon and announce assertively; every other tone is purely cosmetic — no icon, polite — so a pink awareness banner just works.

Accents

accent
Any tone renders cleanly.
accent-2
Any tone renders cleanly.
accent-3
Any tone renders cleanly.
accent-4
Any tone renders cleanly.
neutral
Any tone renders cleanly.

Statuses

success
Any tone renders cleanly.
info
Any tone renders cleanly.

Named hues

red
Any tone renders cleanly.
orange
Any tone renders cleanly.
yellow
Any tone renders cleanly.
green
Any tone renders cleanly.
blue
Any tone renders cleanly.
purple
Any tone renders cleanly.
brown
Any tone renders cleanly.
pink
Any tone renders cleanly.
cyan
Any tone renders cleanly.
gray
Any tone renders cleanly.
white
Any tone renders cleanly.
black
Any tone renders cleanly.

Alert presents a persistent, inline message. Two axes drive it independently.

severity (success, warn, danger, info) carries the meaning: the leading status glyph and the live-region politeness. tone carries the color, drawn from the full palette (semantic roles, accent variants, or named hues). By default a severity paints itself its standard color (danger reads red), but a tone overrides that, so a danger can be repainted pink and still announce as danger, while a color-only notice (a pink awareness banner with no severity) shows no glyph and announces politely. A soft variant tints the banner; a solid variant fills it for higher emphasis. An optional title sits above the message, an actions footer holds buttons, and a dismissible form adds a close button (also closable with Escape) that emits a dismiss event before removing the banner.

When to use

How this component composes with the rest of the set.

Drop Button components into the actions slot for primary/secondary responses; match the button tone to the alert tone.
For transient, auto-dismissing notices use Toast instead; Alert is for persistent inline messages.
The leading icon is built in per severity; project your own into the icon slot to override it, or to mark a color-only notice that carries no severity.

Props

5 props, straight from the manifest.

PropTypeDefaultBindingsDescription
tone AlertTone
accent neutral danger success warn info accent-2 accent-3 accent-4 red orange yellow green blue purple brown pink cyan gray white black
html svelte astro
The banner color — any semantic role, accent variant, or named hue. Defaults to the `severity` color (info when neither is set). Set it to recolor a severity (a pink `danger`) or to tint a color-only notice (a pink awareness banner).
severity AlertSeverity
success warn danger info
html svelte astro
The meaning, independent of color: drives the leading status glyph and the live-region politeness (`danger`/`warn` announce assertively). Omit for a color-only notice with no glyph. A bare status-named `tone` (e.g. `danger`) implies the matching severity.
variant AlertVariant
soft solid
soft
html svelte astro
Visual treatment: a soft tone tint or a solid tone fill.
dismissible boolean false
html svelte astro
Adds a close button and Escape-to-close; emits a cancelable `dismiss` event before removing the banner.
dismissLabel string Dismiss
html svelte astro
Accessible label for the close button (kebab `dismiss-label` on the custom element).

Appearance

Variants

soft

.xoji-alert--soft

A soft tone-tinted background with tone-colored text, border, and icon.

solid

.xoji-alert--solid

Filled with the tone color and reverse ink; the high-emphasis treatment.

Sizes

md

default
.xoji-alert

The single size.

States

dismiss-hover

.xoji-alert__dismiss:hover::after

Pointer over the close button. Overlay paints the hover tint.

dismiss-active

.xoji-alert__dismiss:active::after

Close button pressed. Overlay paints the press tint.

dismiss-focus-visible

.xoji-alert__dismiss:focus-visible

Keyboard focus on the close button: a token-colored ring plus a transparent outline that the forced-colors base rule promotes.

Anatomy

The named parts that make up the component, with their selectors.

alert

.xoji-alert

The banner root carrying the variant and tone classes plus the live-region role.

--space-3 --font-sans --text-body --leading-normal --border-thin --radius-md --space-4

icon

.xoji-alert__icon

The leading status glyph, shown when a severity is set, drawn in the banner color and hidden from assistive tech. Project an icon slot to override it (the slot shows even on a severity-less banner).

--text-lg --space-0

body

.xoji-alert__body

The vertical stack holding the title, message, and actions.

--space-1

title

.xoji-alert__title

The optional bold heading above the message.

--weight-semibold --text-lg --leading-tight --fg-0

message

.xoji-alert__message

The default-slot body copy.

actions

.xoji-alert__actions

The footer row of buttons rendered below the message.

--space-2 --space-1

dismiss

.xoji-alert__dismiss

The close button shown in the dismissible form, with its own hover/press overlay and focus ring.

--text-lg --space-0 --space-1 --border-thin --radius-sm --duration-fast --ease-standard

Tokens & coverage

What the component consumes, checked live against what the algorithm produces.

Success:fully covered 106/106 consumed tokens produced default register: 276 tokens

Live coverage check against the xoji-default register (derive(xojiDefault, { anchors })coverComponent(manifest, register)). Every token this component consumes must be a key the algorithm produces.

--accent --accent-2 --accent-2-bg --accent-2-fg --accent-2-text --accent-3 --accent-3-bg --accent-3-fg --accent-3-text --accent-4 --accent-4-bg --accent-4-fg --accent-4-text --accent-bg --accent-fg --accent-text --black --black-bg --black-fg --black-text --blue --blue-bg --blue-fg --blue-text --border-normal --border-thick --border-thin --brown --brown-bg --brown-fg --brown-text --cyan --cyan-bg --cyan-fg --cyan-text --danger --danger-bg --danger-fg --danger-text --duration-fast --ease-standard --fg-0 --font-sans --gray --gray-bg --gray-fg --gray-text --green --green-bg --green-fg --green-text --info --info-bg --info-fg --info-text --leading-normal --leading-tight --neutral --neutral-bg --neutral-fg --neutral-text --orange --orange-bg --orange-fg --orange-text --pink --pink-bg --pink-fg --pink-text --purple --purple-bg --purple-fg --purple-text --radius-md --radius-sm --red --red-bg --red-fg --red-text --ring --space-0 --space-1 --space-2 --space-3 --space-4 --state-hover --state-press --success --success-bg --success-fg --success-text --text-body --text-lg --warn --warn-bg --warn-fg --warn-text --weight-semibold --white --white-bg --white-fg --white-text --yellow --yellow-bg --yellow-fg --yellow-text

Slots

default
html svelte astro

The message body.

title
html svelte astro

An optional bold heading above the message.

actions
html svelte astro

A footer row of buttons rendered below the message.

icon
html svelte astro

Overrides the built-in severity glyph; fill it to show your own icon (or to mark a severity-less notice).

Accessibility

Live-region semantics follow severity, not color: danger/warn render role="alert" with aria-live="assertive", success/info render role="status" with aria-live="polite", and a severity-less notice is polite role="status".
The leading status glyph is decorative (aria-hidden) and appears only with a severity; meaning is carried by the text and the role, never by color alone.
The dismissible form is closable by pointer or the Escape key and exposes an accessible label on the close button (dismissLabel, default "Dismiss").
Dismissing fires a cancelable dismiss event; calling preventDefault() keeps the banner in place so a host can run its own removal animation.
Focus on the close button shows the token ring plus a transparent outline that the forced-colors base rule promotes to a real system outline.

Code

Tones, variants, and dismissal

The four status tones across the soft and solid variants, with an optional title, an actions footer, and the dismissible form.

<xoji-alert tone="info" variant="soft">
	<span slot="title">Heads up</span>
	Your changes are saved locally and will sync when you reconnect.
</xoji-alert>

<xoji-alert tone="success" variant="soft">Profile updated.</xoji-alert>

<xoji-alert tone="danger" variant="solid" dismissible>
	<span slot="title">Upload failed</span>
	The file exceeded the 25 MB limit.
	<span slot="actions">
		<xoji-button variant="outline" tone="danger">Try again</xoji-button>
	</span>
</xoji-alert>
<script lang="ts">
	import { Alert, Button } from "@xoji/svelte";
</script>

<Alert tone="info">
	{#snippet title()}Heads up{/snippet}
	Your changes are saved locally and will sync when you reconnect.
</Alert>

<Alert tone="success">Profile updated.</Alert>

<Alert tone="danger" variant="solid" dismissible ondismiss={() => retry()}>
	{#snippet title()}Upload failed{/snippet}
	The file exceeded the 25 MB limit.
	{#snippet actions()}
		<Button variant="outline" tone="danger">Try again</Button>
	{/snippet}
</Alert>
---
import { Alert, Button } from "@xoji/astro";
---

<Alert tone="info">
	<Fragment slot="title">Heads up</Fragment>
	Your changes are saved locally and will sync when you reconnect.
</Alert>

<Alert tone="success">Profile updated.</Alert>

<Alert tone="danger" variant="solid" dismissible>
	<Fragment slot="title">Upload failed</Fragment>
	The file exceeded the 25 MB limit.
	<Button slot="actions" variant="outline" tone="danger">Try again</Button>
</Alert>