Skip to main content
Copy for LLM

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.

Sandbox
Warning:
Heads up
Validate every input before submitting.

Basic Usage

Simple alert
Information:
A new version of WireKit is available.

Variants

Each intent has a distinct semantic meaning and color. The background is a subtle tint derived via color-mix() from the matching token.

All four intents
Information:
Heads up — this is informational.
Success:
Your changes have been saved.
Warning:
Your trial expires in 3 days.

With Title

Alert with title
Warning:
Unsaved changes
You have unsaved changes that will be lost if you leave this page.

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.

Dismissible alert
Information:
Tip
You can personalize this theme in your settings.

Actions Slot

Attach action buttons below the message via the actions slot:

Alert with actions

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.

Alert without icon
Information:
A quieter alert, no icon.
All four intents without icons
Information:
Heads up — this is informational.
Success:
Your changes have been saved.
Warning:
Your trial expires in 3 days.

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: danger alerts use role="alert" (assertive announcement). All other intents use role="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::callout>. The semantic difference matters for screen readers.
  • 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::toast-region> for transient notifications.

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/wirekit.php:

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

Updated in WireKit v2.66.0 (2026-10-13)

Was this page helpful?

Thank you for your feedback!

Voting requires cookies or local storage. What we store