---
title: "Alert"
description: "A message in the page with an icon, a title, and text. It tells people about a status, such as a failed payment, and stays until the cause goes away."
url: https://gelatinui.com/components/alert
markdown_url: https://gelatinui.com/components/alert.md
access: free
install: "npx shadcn@latest add @gelatin-ui/alert"
registry_item: https://gelatinui.com/r/alert.json
version: "2026-11-08"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Alert

> A message in the page with an icon, a title, and text. It tells people about a status, such as a failed payment, and stays until the cause goes away.

Page: https://gelatinui.com/components/alert

## When to use it

Best for: A message that stays in the page until its cause goes away.

- Use it for a message that stays in the page until the cause goes away.
- Put the icon first, then `AlertTitle`, then `AlertDescription`. Each part is optional.
- Use `success`, `warning`, or `info` for a status. Put the `inverse` class on an alert that must stand out from the page.
- It has `role="alert"`, so a screen reader reads it at once. For a message that is not urgent, pass `role="status"`.

## When not to use it

- For a short note after an action that closes on its own, use a [Toast](https://gelatinui.com/components/toast.md).
- To ask a yes or no question before an action, use an [Alert Dialog](https://gelatinui.com/components/alert-dialog.md).

## Notes for agents

- Compose it from parts: `Alert`, then an icon, `AlertTitle`, and `AlertDescription`. It does not close on its own.
- Pick a status with `variant`; it has 5 variants and an inverse look.

## Anatomy

```text
Alert
├─ AlertTitle (0..n)
├─ AlertDescription (0..n)
└─ AlertAction (0..n)
```

## API reference

### Alert

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `variant` | `"default" \| "destructive" \| "info" \| "success" \| "warning"` | "default" |  |

### AlertTitle

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### AlertDescription

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### AlertAction

No props of its own: `className`, `children`, and every other prop go to the element it renders.

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| Alert | `alert` |  |  | `status-colors` |
| AlertTitle | `alert-title` |  |  |  |
| AlertDescription | `alert-description` |  |  |  |
| AlertAction | `alert-action` |  |  |  |

## Usage

Put the icon first, then `AlertTitle` and `AlertDescription`. The alert has `role="alert"`, so pass `role="status"` for a message that is not urgent.

The sample also uses `button`, which this add does not write. One command adds them with this item:

```bash
npx shadcn@latest add @gelatin-ui/alert @gelatin-ui/button
```

```tsx title="payment-alert.tsx"
import { XCircleIcon } from "@phosphor-icons/react/ssr";

import { Alert, AlertAction, AlertDescription, AlertTitle } from "@/components/ui/alert";
import { Button } from "@/components/ui/button";

export function PaymentAlert() {
  return (
    <Alert variant="destructive">
      <XCircleIcon />
      <AlertTitle>Payment failed</AlertTitle>
      <AlertDescription>Your card was declined. Update your billing details.</AlertDescription>
      <AlertAction>
        <Button size="xs" variant="outline">
          Update card
        </Button>
      </AlertAction>
    </Alert>
  );
}
```

## Compose

Build it with:

- [Form](https://gelatinui.com/components/form.md): Owns the submit and the errors.
- [Field](https://gelatinui.com/components/field.md): Names each control and shows its error text.
- [Input](https://gelatinui.com/components/input.md): Takes short text.
- [Textarea](https://gelatinui.com/components/textarea.md): Takes long text.
- [Stepper](https://gelatinui.com/components/stepper.md): Shows the steps of a long form.
- [Dialog](https://gelatinui.com/components/dialog.md): Holds a short form over the page.
- [Button](https://gelatinui.com/components/button.md): Submits or moves to the next step.

Rules:

- Name every control (`label-every-control`): Give every field a visible `Label` (or a `Field`), and every icon button a `Tooltip` or an `aria-label`.
- Labels real apps use (`real-labels`): Write the button and menu labels that real apps use ("Create API key", "Invite members"), with no "…" at the end.
- No layout jump (`no-layout-jump`): When a state change adds, removes, or resizes content, reserve its space or animate its size, so nothing below it jumps.
- Touch targets (`touch-targets`): Give every control a hit area of at least 44 px on touch screens, even when it looks smaller.

Patterns: `gelatin://patterns/form-flow`

## Add it

```bash
npx shadcn@latest add @gelatin-ui/alert
```

It adds 7 registry items: 4 files, 1170 lines, and the npm packages `clsx`, `tailwind-merge`, `tailwind-variants`.

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Toast](https://gelatinui.com/components/toast.md): Pick Toast for a short note after an action that stacks in a corner and closes on its own.
- [Alert Dialog](https://gelatinui.com/components/alert-dialog.md): Pick Alert Dialog to ask a yes or no question before an action, in a window that blocks the page.
- [Badge](https://gelatinui.com/components/badge.md)
- [Announcement Bar](https://gelatinui.com/components/announcement-bar.md): Pick Announcement Bar for one site-wide message across the top of the page, such as news or an offer.

## Accessibility

Alert is a `<div>` with `role="alert"`. A screen reader reads it at once when it shows, and stops what it reads. Pass `role="status"` for a message that is not urgent: the screen reader waits until the user is idle. Pass `role="none"` for a note that is in the page from the start.

The variant changes only colors. Put the meaning in the words of `AlertTitle` and `AlertDescription`, so the message does not depend on color.

The alert takes no focus and does not close on its own. A Button in `AlertAction` stays in the normal tab order.
