Skip to main content
WireKit
Copy for LLM

Alert

An inline notification banner for surfacing status, warnings, or errors. Alerts support four semantic variants, 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 variant has a distinct semantic meaning and color. The background is a subtle tint derived via color-mix() from the matching token.

All four variants
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 variant 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 variants 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" variant="info">Narrow alert.</x-wirekit::alert>

{{-- Fixed width --}}
<x-wirekit::alert class="w-96" variant="success">Fixed 384px wide.</x-wirekit::alert>

{{-- Center a constrained alert --}}
<x-wirekit::alert class="max-w-md mx-auto" variant="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 is a visual synonym of info (both tint with --color-wk-accent); 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 variant icon
animateIn string|null null Entrance-reveal preset (e.g. 'fade', 'slide-up', 'scale-in') — inline alternative to wrapping in <x-wirekit::reveal>. See docs/animations.md 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 variant-derived default icon

Accessibility

  • Role: danger alerts use role="alert" (assertive announcement). All other variants use role="status" (polite).
  • Screen reader prefix: Each alert starts with a visually hidden variant label ("Warning: ...", "Error: ...") so the variant 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

This component is purely presentational and does not respond to keyboard input.

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 info variant icon + border tint
--color-wk-success success variant icon + border tint
--color-wk-warning warning variant icon + border tint
--color-wk-danger danger variant icon + border tint
--color-wk-bg-elevated Base background mixed into variant 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 variant 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.

Was this page helpful?

Thanks — that helps.

Voting requires cookies or local storage. What we store