Skip to content
Haze UI

Alert

Inline message panel with a status icon, title, optional description and action slot, in five variants.

pnpm dlx shadcn@latest add @haze/alert
Open preview in a new tab
Liveno JavaScript

When to use

  • A message that stays in the flow of the page, such as a billing notice or a failed import
  • Telling the reader what happened and offering one follow-up action
  • Status messages that need an icon and text, not only a tint

When not to use

  • A short-lived confirmation that should disappear on its own
  • A blocking decision that needs a dialog

Installation

Add the Haze registry to components.json once, then install Alert with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.

pnpm dlx shadcn@latest add @haze/alert
First time? Registry and theme setup

1. Add to components.json:

{
  "registries": {
    "@haze": "http://localhost:4329/r/{name}.json"
  }
}

2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";

API reference

PropTypeDefaultDescription
variant"default" | "info" | "success" | "warning" | "destructive""default"Picks the icon and the tint of the panel: a 25% border and 8% fill for the four status variants, the card surface for default.
title*string–First line, rendered as a paragraph in medium weight.
classstring–Extra classes on the box.
...restHTML attributes–Passed to the box; add role="alert" for messages inserted after load.
default slotslot–Description text under the title.
actionslot–A button or link, shown to the right of the text on wide layouts and under it on narrow ones.

Accessibility

  • The action sits to the right of the text on wide layouts and below it on narrow ones.
  • No role is set by default, so an alert that is part of the page does not interrupt screen readers; pass role="alert" when you insert it after load.
  • Each status has its own icon shape: a circle with a check for success, a triangle for warning and a circle with a cross for destructive. Default and info share the circle with an i, and differ by color and by the title text, so the status is not carried by color alone.
  • The title is a paragraph, not a heading, so it never disturbs the outline of the page.

Notes for AI

Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.

  • Install and use

    Install the Haze UI component "Alert" with `npx shadcn@latest add @haze/alert`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import Alert from "@/components/haze/ui/alert.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/ui/alert.md

  • Customize with real content

    Adapt the Haze alert ui for our product. Replace the demo values of these props with our real content: variant, title, class, ...rest, default slot, action. Keep the layout, the heading level rules and these accessibility details: The action sits to the right of the text on wide layouts and below it on narrow ones. No role is set by default, so an alert that is part of the page does not interrupt screen readers; pass role="alert" when you insert it after load. Each status has its own icon shape: a circle with a check for success, a triangle for warning and a circle with a cross for destructive. Default and info share the circle with an i, and differ by color and by the title text, so the status is not carried by color alone. The title is a paragraph, not a heading, so it never disturbs the outline of the page. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using alert, check it fits: use it when a message that stays in the flow of the page, such as a billing notice or a failed import; telling the reader what happened and offering one follow-up action; status messages that need an icon and text, not only a tint. Avoid it when a short-lived confirmation that should disappear on its own; a blocking decision that needs a dialog. Alternatives: @haze/status, @haze/dialog, @haze/empty.

Dependencies

  • npm: @lucide/astro
  • @haze/utils
  • @haze/theme (one-time setup)

Source · Original Haze UI work.

Catalog

↑↓ moveEnter openEsc close

Keyboard shortcuts

CtrlK
Command palette
/
Focus search
←↑→↓
Move between cards
jk
Next / previous card
ci
Copy code / install command (detail page)
[]
Previous / next entry
?
This help
Esc
Close dialog