A message in the page with an icon, optional actions and a close button.
Default
A one-line info alert in the soft lighter style.
Denzing viewed the brand refresh proposal.
Installation
Copies the component into src/design-system/ as your own source, with only the files it needs.
npx avesk-ui@latest add alertBrings the 2 files it builds on (button.tsx, glyph.tsx). The first time, it also adds the tokens and the cn() helper, imports the tokens in globals.css and installs clsx and tailwind-merge. Files already in your project are kept unless you add --force.
Import
Lives in src/design-system/components/alert.tsx.
import { Alert } from "@/design-system/components/alert";Usage
<Alert tone="warning" title="2 invoices are overdue" action={{ label: "Open invoices", href: "/finance/payments" }} />Examples
Tones
Error, warning, success, info and neutral, each with its own icon and colour.
Invoice #1042 could not be sent.
Invoice #1038 is 5 days overdue.
Proposal approved by Denzing.
Northwind left 3 new comments.
Drafts are only visible to your team.
Variants
filled, light, lighter (default) and stroke, from loudest to quietest.
Brand guidelines published.
Brand guidelines published.
Brand guidelines published.
Brand guidelines published.
Large with actions
The lg size adds a description, a main action and a second action.
Invoice #1038 is overdue
Ferro Coffee was due to pay £4,200 on 13 November. Send a friendly reminder?
Dismissible
Pass onClose to show a close button; the alert hides when dismissed.
When to use
Use it when
- Something the person should know while they stay on the page: an overdue invoice, a failed save, a tip
- A banner at the top of a section
Don’t use it when
- Confirming an action that just happened → Toast
- An error on one form field → Field and inputs (error)
- It must be answered before continuing → Dialog
- A status label on a row → Badge
Rules
- Tone: error = something failed, warning = needs attention, success = done, info = neutral fact, neutral = feature or tip
- Default style is lighter; use filled sparingly
- xs and sm are one line; lg has a description and up to two actions
Properties
Alert
| Prop | Type | Default |
|---|---|---|
title * | ReactNode | – |
description | ReactNode | – |
tone | "error" | "warning" | "success" | "info" | "neutral" | "info" |
variant | "filled" | "light" | "lighter" | "stroke" | "lighter" |
size | "xs" | "sm" | "lg" | "sm" |
action | AlertAction | – |
secondaryAction | AlertAction | – |
onClose | () => void | – |
role | "alert" | "status" | "group" | – |
className | string | – |
* required
Accessibility
- Errors use role="alert"; others role="status"
- The tone is also announced in words