Alert
An inline notification banner for surfacing status, warnings, or errors. Alerts support six semantic intents, optional titles, actions, and dismissal.
Live Sandbox
This is a hydrated playground for the component. Toggle "Live preview" on the block below to swap the static HTML render for a real Livewire instance — every prop in the component's sandbox schema becomes an editable form field inside the iframe, so you can try different prop combinations live without writing any local code.
Basic Usage
Variants
Each intent has a distinct semantic meaning and color. The background is a subtle tint derived via color-mix() from the matching token.
With Title
Dismissible
Add dismissible to render a close button. Dismissal is handled by a tiny Alpine x-data block — no JavaScript bundle additions beyond the existing Alpine.
Actions Slot
Attach action buttons below the message via the actions slot:
Without Icon
Hide the default intent icon with :icon="false". This yields a quieter look — useful inside compact layouts or when the surrounding copy already conveys the severity.
Width & Layout
Alerts are block-level elements that fill their parent container by default. Control the width with Tailwind utility classes directly on the component — class is applied to the root element:
{{-- Constrain to a max width --}}
<x-wirekit::alert class="max-w-lg" intent="info">Narrow alert.</x-wirekit::alert>
{{-- Fixed width --}}
<x-wirekit::alert class="w-96" intent="success">Fixed 384px wide.</x-wirekit::alert>
{{-- Center a constrained alert --}}
<x-wirekit::alert class="max-w-md mx-auto" intent="warning">Centered alert.</x-wirekit::alert>
Height is determined automatically by the content. The alert grows to fit its message, title, and actions.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
variant |
string | 'info' |
primary, neutral, info, success, warning, danger. primary tints with --color-wk-accent and info with --color-wk-info-tone, which is the accent until you give info a color of its own; neutral is a quiet gray treatment for non-severity-bearing notices. See Variants & Intents for the cross-component reference. |
intent |
string|null | null |
Canonical name for the color axis — the same spelling Button and Badge use: primary, neutral, info, success, warning, danger. Falls back to variant when omitted, and wins over it when both are given. |
title |
string|null | null |
Optional bold title above the body |
dismissible |
bool | false |
Show a close button that hides the alert |
icon |
bool | true |
Whether to render the default intent icon |
animateIn |
string|null | null |
Entrance-reveal preset (e.g. 'fade', 'slide-up', 'scale-in') — inline alternative to wrapping in <x-wirekit::reveal>. See Animations for the full preset list. Respects prefers-reduced-motion: reduce. |
scope |
string|null | null |
Scoped personalization name |
Slots
| Slot | Description |
|---|---|
| Default | Body text content |
title |
Bold heading above the body |
actions |
Action buttons/links below the body |
iconSlot |
Custom icon that overrides the intent-derived default icon |
Accessibility
- Role:
dangeralerts userole="alert"(assertive announcement). All other intents userole="status"(polite). - Screen reader prefix: Each alert starts with a visually hidden intent label (
"Warning: ...","Error: ...") so the intent is announced even without visual context. - Icons are decorative — marked
aria-hidden="true"since the meaning is conveyed by the text. - Dismiss button has
aria-label="Dismiss"and visible focus ring.
Keyboard Interaction
With dismissible, the alert renders a real <button>: it takes Tab focus, shows the focus ring, and Enter / Space dismiss it. The focus then moves to the next control after the alert (or the last one before it), so the next Tab continues from where the alert was. Actions placed in the alert are ordinary focusable controls in source order. A plain alert has no interactive element.
Pitfalls
- Don't use an alert as a permanent UI element. Alerts are status messages — for persistent banners, use
<x-wirekit::. The semantic difference matters for screen readers.callout> - Don't show ten alerts at once. WCAG 2.4.3 (Focus Order) suffers when multiple
aria-live="assertive"regions fire simultaneously. Group related warnings into a single alert with a list, or use<x-wirekit::for transient notifications.toast-region>
Design Tokens
| Token | Purpose |
|---|---|
--color-wk-accent |
primary intent icon + border tint |
--color-wk-info-tone / --color-wk-info-text |
info intent border tint / icon |
--color-wk-success |
success intent icon + border tint |
--color-wk-warning |
warning intent icon + border tint |
--color-wk-danger |
danger intent icon + border tint |
--color-wk-bg-elevated |
Base background mixed into intent tint |
--color-wk-text / --color-wk-text-muted |
Title / body text |
--radius-wk-md |
Corner radius |
Backgrounds are built with color-mix() — a 10% mix of the intent color into the elevated background. This keeps tints visually consistent across themes.
Customization
Override the default variant in config/:
'components' => [
'alert' => ['variant' => 'warning'],
],
Usage & Conventions
Prop conventions — this component uses one or more of the shared semantic prop names (
intent/variant/tone/surface). See Prop naming conventions for the canonical vocabulary, alias matrix, and decision tree.