Command Palette

Search for a command to run...

Docs
Alert

Alert

Displays a callout for user attention with various styles, sizes, and icon options.

Installation

Run the following command:

Update your imports:
import { Alert, AlertTitle, AlertDescription } from "@/components/ui/alert"

Usage

import { Alert, AlertTitle, AlertDescription } from "@/components/ui/alert";
import { AlertCircle } from "lucide-react";
 
export default function Home() {
  return (
    <Alert>
      <AlertCircle />
      <AlertTitle>Heads up!</AlertTitle>
      <AlertDescription>You can add components to your app using the CLI.</AlertDescription>
    </Alert>
  );
}

Props

Alert

PropTypeDefaultDescription
variantdefault | destructive | success | warning | info | outlinedefaultStyle variant of the alert
sizesm | default | lgdefaultSize of the alert
withIconbooleantrueShow space for icon
iconReact.ReactNode-Custom icon element to display

HTML Attributes

All Alert components support standard HTML attributes:

Alert

Standard HTML div attributes:
  • id
  • role (automatically set to "alert")
  • aria-* attributes
  • data-* attributes
  • Event handlers like onClick, onMouseEnter, etc.

AlertTitle and AlertDescription

Standard HTML div attributes and event handlers.
The Alert components ensure proper accessibility by providing appropriate role attributes and semantic structure.