Documentation
Feedback Alert

Alert

Alert components for displaying important messages and status updates.

Interactive Demo

Default Alert

Heads up!
You can add components to your app using the CLI.

Destructive Alert

Custom Content

Success!

Your changes have been saved successfully.

The Alert component displays important messages and status updates with optional icon, title, and description slots. It supports default and destructive variants for different severity levels.

Import

use PUI
# or
import PUI.Alert

Basic Usage

<.alert>
<:title>Heads up!</:title>
<:description>You can add components to your app using the CLI.</:description>
</.alert>

With Icon

Add an icon to draw attention:

<.alert>
<:icon>
<.icon name="hero-information-circle" class="size-5" />
</:icon>
<:title>Information</:title>
<:description>This is an informational alert message.</:description>
</.alert>

Destructive Variant

Use the destructive variant for error or warning messages:

<.alert variant="destructive">
<:icon>
<.icon name="hero-exclamation-triangle" class="size-5" />
</:icon>
<:title>Error</:title>
<:description>Something went wrong. Please try again.</:description>
</.alert>

Custom Content

Use inner_block for fully custom alert content:

<.alert>
<div class="flex items-center gap-3">
<.icon name="hero-check-circle" class="size-5 text-green-500" />
<div>
<p class="font-semibold">Success!</p>
<p class="text-sm">Your changes have been saved.</p>
</div>
</div>
</.alert>

Unstyled / Headless

<.alert variant="unstyled" class="my-custom-alert">
<:title>Custom Alert</:title>
<:description>With your own styles.</:description>
</.alert>

API Reference

Attributes

Name Type Default Description
variant string "default" Visual style: "default", "destructive", "unstyled"
class string "" Additional CSS classes
role string nil ARIA role attribute

Slots

Name Required Description
icon Icon element displayed at the start
title Alert title (supports class)
description Alert description text (supports class)
inner_block Custom content (alternative to named slots)