Avara UI

Shadcn Alert

An inline alert banner for persistent status messages in six severity types and five surface variants (inset, default, soft, glass, and solid).

Applies to this page's previews only

About Shadcn Alert

What it is. Alert is an inline banner with six type values (neutral, info, success, warning, danger and loading) and five variant surfaces (inset, default, soft, glass, solid). It takes a title, a message, an optional action slot and a dismissible close button. AlertAction is the matching pill button.

How it is built. The type picks an animated icon (from ui-animated-icons) and a colour, and the variant picks the surface. danger and warning render with role="alert", the other types with role="status", and loading adds aria-busy with a spinning icon. Dismissing fades the alert out over 200 ms and then calls onDismiss.

When to use it. Use Alert for persistent in-page banners, form summaries and system notices that stay in the layout. For notifications that disappear on their own, use Toast or Sonner.

For AI agents

Hand your agent this brief or the Markdown page, not a screenshot.

When to use

  • Persistent inline callouts, validation summaries, and status banners inside page layouts or forms
  • Visual variants (inset, default, soft, glass, solid) matched to light, dark, or image/gradient backdrops

When not to use

  • Temporary floating notifications: use Sonner or Toast
  • Blocking confirmations: use Dialog

Agent notes

  • Named exports Alert and AlertAction from @/components/custom/blocks/Alerts; there is no default export.
  • type is "neutral" | "info" | "success" | "warning" | "danger" | "loading". There is no error or destructive type: use danger.
  • variant="glass" applies backdrop blur and white text, so it needs an image or gradient behind it.
  • Dismissal is internal: the alert hides itself after the fade, and onDismiss is only a notification, not a controlled open prop.
  • Put AlertAction in the action slot or inside children; it takes its colour from the alert's type and variant.
For AI agents4 variants. Ask the user which one.

Ask before you pick. This page has 4 variants. If the user has not named one and has not asked you to choose for them, ask which they want before you install anything or write code, and show every option with its live link. If they ask you to choose, pick from each variant's best-for and avoid-if lines against their brief, and say why. If the user named a variant, use it and do not ask.

All 4 options as live previews: https://avaraui.com/view/alert

When to use it. An inline alert for messages that stay in the layout, with six types (neutral, info, success, warning, danger, loading), an action button slot and optional dismiss, in four styles: default, soft, glass and solid.

When to use something else

  • Toast: the message is short-lived and should float over the page instead of sitting in the layout.

Gotchas

  • All four are looks of the one `alert` item: install it once and set `variant` from the index.
  • The type picks the icon and the colour on every style; it says what the alert is about, so choose it by meaning, not by taste.
  • Glass uses white text and needs an image or gradient behind it; on a plain background use another style.

The 4 variants

  1. Default default

    A card surface where only the icon carries the type colour.

    • Best for: a restrained interface where the alert should not shout
    • Avoid if: the alert has to be noticed at a glance
    • Traits: card surface, coloured icon only
    • Install: npx shadcn@latest add @avara-ui/alert
    • Docs section
  2. Soft soft

    A pale card with the type colour bleeding in from the left corners.

    • Best for: form-level and page-level messages that should read by colour
    • Avoid if: you want a plain card with no tint
    • Traits: corner gradient, dark text, paired footer buttons
    • Install: npx shadcn@latest add @avara-ui/alert
    • Docs section
  3. Solid solid

    A flat light fill of the standard type colour with a matching border.

    • Best for: banners that should read by colour at a glance
    • Avoid if: you want a card with no tint at all
    • Traits: flat tinted fill, coloured icon, filled action buttons
    • Install: npx shadcn@latest add @avara-ui/alert
    • Docs section
  4. Glass glass

    A frosted alert with a type-coloured tint and icon.

    • Best for: an interface over imagery or gradients
    • Avoid if: the background is plain and there is nothing to frost
    • Traits: frosted blur, white text, needs a backdrop
    • Install: npx shadcn@latest add @avara-ui/alert
    • Docs section
Install
npx shadcn@latest add https://avaraui.com/r/alert.json
Registry name
@avara-ui/alert, through the shadcn MCP server
Index
llms.txt lists every page, or add the agent skill once

Props Reference

PropTypeDefaultDescription
type

"neutral" | "info" | "success" | "warning" | "danger" | "loading"

"neutral"What the alert is about. Sets the icon and the colour.
variant"inset" | "default" | "soft" | "glass" | "solid""default"The visual style.
titleReactNodeundefinedThe bold heading.
messageReactNodeundefinedThe text under the title.
iconReactNode | nullThe icon for the type

Replaces the icon. Pass null to hide it.

actionReactNodeundefined

Slot on the right, usually an AlertAction.

dismissiblebooleanfalseAdds a close button that fades the alert out.
onDismiss() => voidnullCalled after the fade, so you can drop the alert from your state.
childrenReactNodeundefinedExtra content under the message, such as a list.
classNamestringundefinedClasses for the alert root.
titleClassNamestringundefinedClasses for the title.
messageClassNamestringundefinedClasses for the message.
iconClassNamestringundefinedClasses for the icon wrapper.

Works with other components

  • Pair Alert above Form or Input groups for server-side validation summaries.
  • Use Toast or Sonner when feedback should appear temporarily and auto-dismiss.
  • Embed inside Dialog to highlight destructive action warnings.

How do I show an error alert with the Alert component?

Use type="danger". Alert has no error or destructive type, so danger is the red one. It uses the theme's destructive colour on the default and soft variants, renders with role="alert" so screen readers announce it, and pairs with AlertAction for a retry button in the action slot.

When should I use variant="glass" vs variant="soft"?

Use variant="soft" on plain light or dark backgrounds: it bleeds the type colour into a pale card from the left corners. Use variant="glass" over a photo, gradient or mesh background, where its backdrop-blur-xl frosting and white text show through. On a flat background glass loses its effect.

How do I make an Alert dismissible and react to it closing?

Set dismissible to show a close button labelled "Dismiss alert". Clicking it fades the alert out over 200 ms and hides it. onDismiss then runs, so use it to drop the alert from your own state. Alert does not take an open prop to control visibility.

How do I add a button to an Alert?

Pass <AlertAction> to the action prop for a button on the right, or place it inside children for one under the message. AlertAction reads the alert's type and variant for its colours, and appearance="outline" gives a quieter second button beside a filled one.

Does Alert announce itself to screen readers?

Yes, with a role chosen from type. danger and warning use role="alert", which interrupts, while neutral, info, success and loading use role="status", which is polite. The loading type also sets aria-busy, and its spinner and entrance animation respect reduced motion.

What is the difference between Alert and Toast / Sonner?

Alert stays inline in the document flow until the person or your state removes it. Toast and Sonner render floating notifications in a viewport corner that disappear after a duration (Toast defaults to 5000 ms), so use Alert for anything that must stay readable.