Alert
Alerts display short, important messages in a way that attracts the user's attention without interrupting the user's task.
Installation
Add the alert component to your project:
Usage
Default Alert
Alert
Live preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Alert
Full preview from the registry iframe.
Loading preview...
Success Alert
Alert
successLive preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Alert
Full preview from the registry iframe.
Loading preview...
Destructive Alert
Alert
destructiveLive preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Alert
Full preview from the registry iframe.
Loading preview...
Warning Alert
Alert
warningLive preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Alert
Full preview from the registry iframe.
Loading preview...
Info Alert
Alert
infoLive preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Alert
Full preview from the registry iframe.
Loading preview...
Non-dismissible Alert
Alert
Live preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Alert
Full preview from the registry iframe.
Loading preview...
Alert Without Title
Alert
Live preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Alert
Full preview from the registry iframe.
Loading preview...
Props
| Prop | Type | Default | Description |
|---|---|---|---|
variant |
string |
default |
Alert style variant (default, success, destructive, warning, info) |
dismissible |
boolean |
false |
Show dismiss button |
title |
string |
null |
Alert title |
icon |
string |
null |
Override default icon |
Variants
default- Default gray stylingsuccess- Green styling with check icondestructive- Red styling with alert iconwarning- Amber/yellow styling with warning iconinfo- Blue styling with info icon
Examples
Form Success Message
Alert
successLive preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Alert
Full preview from the registry iframe.
Loading preview...
Form Validation Errors
Alert
destructiveLive preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Alert
Full preview from the registry iframe.
Loading preview...
System Status
Alert
warningLive preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Alert
Full preview from the registry iframe.
Loading preview...
Custom Icon
Alert
infoLive preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Alert
Full preview from the registry iframe.
Loading preview...
Customization
You can customize the alert component by modifying the variant classes:
@
@props([
'variant' => 'default',
'dismissible' => false,
'title' => null,
'icon' => null,
])
@php
$variantClasses = match($variant) {
'success' => 'bg-emerald-50 dark:bg-emerald-950/30 border-emerald-200 dark:border-emerald-800 text-emerald-900 dark:text-emerald-100',
'destructive' => 'bg-destructive/10 border-destructive/20 text-destructive',
// ... add your custom variants
};
@endphp
<div {{ $attributes->class(['relative w-full rounded-lg border p-4', $variantClasses]) }}>
{{ $slot }}
</div>
Accessibility
Alerts include:
- ARIA role="alert" - Screen readers announce alerts immediately
- Dismissible button - Properly labeled for screen readers
- Color contrast - Meets WCAG AA standards
- Keyboard accessible - Dismissible via keyboard
Animation
Alerts include smooth transitions for dismiss action:
- Fade in - Smooth appearance
- Scale - Subtle scale effect
- Fade out - Smooth dismissal
Next Steps
- Explore Button component
- Learn about Dialog component
- View Input component