Alert
Contextual alert banners for feedback, messaging, or inline warnings.
Last updated: July 1, 2025
See all Alerts in the Alerts page.
Overview
The <Alert />
component displays messages to users with contextual styling and optional icons, descriptions, lists, links, and dismiss functionality.
Basic Usage
<Alert
variant="warning"
title="Heads up!"
description="This is a basic warning alert."
/>
Example
Heads up!
This is a basic warning alert.
Props
Prop | Type | Default | Description |
---|---|---|---|
variant | string | "warning" | Visual context (warning , error , info , success , neutral ) |
title | string | "" | Main heading text |
description | string | "" | Supporting content below the title |
list | string[] | [] | Optional list of items to show under the description |
links | object[] | [] | Array of { href, label } for link buttons below the alert |
dismissible | boolean | false | Shows a close button if true |
icon | Component | null | undefined | Custom icon component (pass null to hide) |
role | string | "alert" | ARIA role (alert , status , etc.) for accessibility |
Variants
<Alert variant="warning" title="Caution" description="This is a warning." />
<Alert variant="error" title="Error" description="Something went wrong." />
<Alert variant="info" title="Info" description="Here’s some additional context." />
<Alert variant="success" title="Success" description="Your action was successful." />
<Alert variant="neutral" title="Note" description="This is a neutral alert." />
Example
Caution
This is a warning.
Error
Something went wrong.
Info
Here’s some additional context.
Success
Your action was successful.
Note
This is a neutral alert.
Lists
<Alert
title="Update Required"
description="Please update the following:"
list={["Node.js v18+", "Astro v4", "Tailwind CSS 3.4"]}
variant="info"
/>
Example
Update Required
Please update the following:
- Node.js v18+
- Astro v4
- Tailwind CSS 3.4
Links
<Alert
title="New Feature"
description="We’ve launched something new."
links={[
{ href: "/docs", label: "View Docs" },
{ href: "/changelog", label: "Changelog" },
]}
variant="success"
/>
Example
Dismissible
<Alert
title="Heads Up!"
description="This alert can be dismissed."
dismissible={true}
/>
Example
Heads Up!
This alert can be dismissed.
Custom Icon
You can override the default icon or remove it entirely:
<Alert
title="No Icon Example"
description="This alert has no icon."
icon={null}
/>
Example
No Icon Example
This alert has no icon.
Or pass your own icon:
import Info from "@/components/fundations/icons/RoundedInfo.astro";
<Alert
variant="info"
title="Custom Icon"
description="Using a custom icon here."
icon={Info}
/>
Example
Custom Icon
Using a custom icon here.
Accessibility
- Alerts use appropriate
role
andaria-live
settings. role="alert"
is assertive for errors; others usepolite
.- Dismiss buttons are keyboard- and screen-reader-friendly.
Best Practices
- Use
error
variant for critical feedback (form failures, system errors). - Use
info
orneutral
for general context or status updates. - Use
success
for confirmations or completed actions. - Avoid using alerts excessively; reserve for meaningful feedback.