Alert

Alert component documentation for Velyx. Installation, usage examples, variants, and customization guidance for Laravel Blade, Alpine.js, Livewire, and Tailwind CSS v4.

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:

npx velyx@latest add alert
pnpm dlx velyx@latest add alert
yarn dlx velyx@latest add alert
bunx --bun velyx@latest add alert

Alpine.js Required: The alert component requires Alpine.js for interactivity (dismiss functionality). Make sure Alpine.js is installed in your project.

Usage

Default Alert

Alert

Live preview rendered from the registry in an isolated iframe.

Open preview

Loading preview...

Failed to load preview

Code

Alert

Full preview from the registry iframe.

Loading preview...

Success Alert

Alert

success

Live preview rendered from the registry in an isolated iframe.

Open preview

Loading preview...

Failed to load preview

Code

Alert

Full preview from the registry iframe.

Loading preview...

Destructive Alert

Alert

destructive

Live preview rendered from the registry in an isolated iframe.

Open preview

Loading preview...

Failed to load preview

Code

Alert

Full preview from the registry iframe.

Loading preview...

Warning Alert

Alert

warning

Live preview rendered from the registry in an isolated iframe.

Open preview

Loading preview...

Failed to load preview

Code

Alert

Full preview from the registry iframe.

Loading preview...

Info Alert

Alert

info

Live preview rendered from the registry in an isolated iframe.

Open preview

Loading preview...

Failed to load preview

Code

Alert

Full preview from the registry iframe.

Loading preview...

Non-dismissible Alert

Alert

Live preview rendered from the registry in an isolated iframe.

Open preview

Loading preview...

Failed to load preview

Code

Alert

Full preview from the registry iframe.

Loading preview...

Alert Without Title

Alert

Live preview rendered from the registry in an isolated iframe.

Open preview

Loading preview...

Failed to load preview

Code

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 styling
  • success - Green styling with check icon
  • destructive - Red styling with alert icon
  • warning - Amber/yellow styling with warning icon
  • info - Blue styling with info icon

Examples

Form Success Message

Alert

success

Live preview rendered from the registry in an isolated iframe.

Open preview

Loading preview...

Failed to load preview

Code

Alert

Full preview from the registry iframe.

Loading preview...

Form Validation Errors

Alert

destructive

Live preview rendered from the registry in an isolated iframe.

Open preview

Loading preview...

Failed to load preview

Code

Alert

Full preview from the registry iframe.

Loading preview...

System Status

Alert

warning

Live preview rendered from the registry in an isolated iframe.

Open preview

Loading preview...

Failed to load preview

Code

Alert

Full preview from the registry iframe.

Loading preview...

Custom Icon

Alert

info

Live preview rendered from the registry in an isolated iframe.

Open preview

Loading preview...

Failed to load preview

Code

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