View fulldotdev/ui on GitHub

Alert

Displays a callout for user attention.

Installation

npx shadcn@latest add @fulldev/alert

Usage

import {
  Alert,
  AlertAction,
  AlertDescription,
  AlertTitle,
} from "@/components/ui/alert"
<Alert>
  <InfoIcon />
  <AlertTitle>Heads up!</AlertTitle>
  <AlertDescription>
    You can add components and dependencies to your app using the cli.
  </AlertDescription>
  <AlertAction>
    <Button variant="outline">Enable</Button>
  </AlertAction>
</Alert>

Alert renders a div with role="alert". Use it for inline feedback in the page flow; for confirmations, use Alert Dialog.

Composition

Alert
├── Icon
├── AlertTitle
├── AlertDescription
└── AlertAction

Basic

A basic alert with an icon, title and description.

Destructive

Use variant="destructive" to create a destructive alert.

Action

Use AlertAction to add a button or other action element to the alert.

Custom Colors

Add classes such as bg-amber-50 dark:bg-amber-950 to Alert to change its colors.

RTL

Set dir="rtl" on Alert or an ancestor.

API Reference

Source: src/components/ui/alert

Alert

PropTypeDefault
variant"default" | "destructive""default"

AlertTitle, AlertDescription and AlertAction render a div and forward class and other attributes. AlertAction is positioned in the top-right corner of the alert.