v0.0.2
Demos (demo panel, opens in a new tab)

Alert

An in-page box that shows the result of an action, a situation that needs attention or a persistent error.

zb:alert zubazar/ui · free (MIT)

Variants

Variants: view
BLADE

Pick the color and icon with variant: info (default) for information, success for success, warning for attention, danger for errors.

variant
blade
<zb:alert variant="info">The October campaign calendar is out.</zb:alert>
blade
<zb:alert variant="success">The October campaign calendar is out.</zb:alert>
blade
<zb:alert variant="warning">The October campaign calendar is out.</zb:alert>
blade
<zb:alert variant="danger">The October campaign calendar is out.</zb:alert>
blade
<zb:alert variant="primary">The October campaign calendar is out.</zb:alert>
blade
<zb:alert variant="secondary">The October campaign calendar is out.</zb:alert>
blade
<zb:alert variant="dark">The October campaign calendar is out.</zb:alert>
PropValues
variantprimary | secondary | success | danger | warning | info | dark (default info)

With a title

With a title: view
BLADE

title adds a bold heading line on top; in alerts with a list or longer text, put the gist of the message there.

blade
<zb:alert variant="danger" title="The import could not be completed">
    <ul class="list-disc space-y-1 ps-4">
        <li>Row 12: SKU is missing.</li>
        <li>Row 27: category code (ELK-09) not found.</li>
    </ul>
</zb:alert>
PropValues
titleBold heading line; when empty, only the content is shown

Dismissible

Dismissible: view
BLADE

dismissible adds a close button at the top right; the alert is hidden only in the browser and comes back on reload.

blade
<zb:alert variant="warning" dismissible>
    4 team members are using an old version of the mobile app.
</zb:alert>
PropValues
dismissibletrue | false

Dismissing with Livewire

BLADE

dismiss-action also calls a Livewire method on close, so you can mark the announcement as read on the server.

blade
@if ($announcement)
    <zb:alert title="{{ $announcement->title }}" dismiss-action="dismissAnnouncement">
        {{ $announcement->body }}
    </zb:alert>
@endif
PropValues
dismiss-actionName of the Livewire method (e.g. dismissAnnouncement)

Props

The values the component takes. What are props and slots?

PropTypeDefaultDescription
variant—infoinfo (sky) · success (emerald) · warning (amber) · danger (red); an unknown value falls back to info
title—nullBold heading line
dismissiblebooleanfalseClose button; hides the alert only in the browser
dismiss-action—nullLivewire method called on close; when given, the close button is added as well

Slots: default: the alert text (may be HTML) or the zb:alert.title and zb:alert.description parts.

Advanced

3 examples

Rich content

Rich content: view
BLADE

The slot accepts free-form HTML: add a link, bold text or a small button. The text color comes from the variant; make links stand out with underline.

blade
<zb:alert variant="info" title="A new version is ready">
    <p>Version <strong>2.4</strong> of the mobile app supports recording orders offline.</p>
    <div class="mt-3 flex flex-wrap items-center gap-3">
        <zb:button size="sm">Start the update</zb:button>
        <a href="#" class="font-medium underline underline-offset-2 hover:no-underline">Release notes</a>
    </div>
</zb:alert>

Accessibility note

Accessibility note: view
BLADE

Give an important error that appears later role="alert", and screen readers announce it at once. Alerts present when the page loads read like ordinary text.

blade
<zb:alert variant="danger" role="alert">Your session has expired. Please sign in again.</zb:alert>
PropValues
rolealert (urgent) | status (informational)

Title and description parts

Title and description parts: view
BLADE

When the alert content includes a list, a link or a button, use the zb:alert.title and zb:alert.description parts; the icon, color and close button stay the same.

blade
<zb:alert variant="warning" dismissible>
    <zb:alert.title>3 shipments are delayed</zb:alert.title>
    <zb:alert.description>
        <ul class="list-disc space-y-0.5 ps-4">
            <li>Kadıköy warehouse: 2 orders, estimated 1 day delay</li>
            <li>Üsküdar warehouse: 1 order, address could not be verified</li>
        </ul>
        <div class="mt-3 flex flex-wrap gap-2">
            <zb:button size="sm" variant="warning">Reschedule the shipment</zb:button>
            <zb:button size="sm" variant="white">Call the carrier</zb:button>
        </div>
    </zb:alert.description>
</zb:alert>

<zb:alert variant="success" class="mt-4">
    <zb:alert.title>Campaign published</zb:alert.title>
    <zb:alert.description>
        The 12-product campaign was emailed to 486 customers.
        <a href="#" class="font-medium underline underline-offset-2">View the campaign</a>
    </zb:alert.description>
</zb:alert>

Developer notes

Events, hooks and details
  • For messages that should disappear after a few seconds, use a toast (zb:toast-container).
  • When dismiss-action is given, the close button appears even without dismissible.

Accessibility

ARIA and roles
The alert box has no role; it reads as ordinary page content. The coloured icon is hidden from screen readers (aria-hidden).
Live announcements
For an alert added later that must be announced at once, add role="alert", or role="status" for a polite one; attributes go on the box. For short-lived messages use zb:toast-container.
Dismissing
dismissible adds a "Close" button in the tab order. Closing hides the box and does not move focus anywhere.
What you provide
Do not rely on colour alone: put a word such as "Error" or "Warning" in the title or text. title renders a bold paragraph, not a heading; add a heading yourself if the page structure needs one.
Zubazar UI · ZubazarDesigned for people.