Skip to content

shadcn.io is not affiliated with official shadcn/ui

Shadcn Alert for React

Displays an alert for user attention.

Installation

bunx --bun shadcn@latest add https://kit.dev/r/radix/alert.json

Usage

import { CheckCircle2Icon, InfoIcon } from "lucide-react";
import {
  Alert,
  AlertDescription,
  AlertTitle,
} from "@/components/ui/alert";
<div className="grid w-full max-w-md items-start gap-4">
  <Alert>
    <CheckCircle2Icon aria-hidden="true" />
    <AlertTitle>Payment successful</AlertTitle>
    <AlertDescription>
      Your payment of $29.99 has been processed. A receipt has been sent to
      your email address.
    </AlertDescription>
  </Alert>
  <Alert>
    <InfoIcon aria-hidden="true" />
    <AlertTitle>New feature available</AlertTitle>
    <AlertDescription>
      We&apos;ve added dark mode support. You can enable it in your account
      settings.
    </AlertDescription>
  </Alert>
</div>

Demos

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.

Colors

Customize alert colors with classes such as bg-amber-50 dark:bg-amber-950.

Rtl

Right-to-left alert. See the RTL configuration guide for document direction.

API Reference

Alert

PropType
AttributeType
data-variant?string

AlertTitle

PropType
AttributeType

AlertDescription

PropType
AttributeType

AlertAction

PropType
AttributeType