Make your AI a shadcn expert

Shadcn Alert

React alert for success, errors, and inline notices on a page. Built with TypeScript and Tailwind CSS for Next.js using Base UI — role=alert, default and destructive.

An alert sits on the page and says what just happened. Use it for form success, a failed payment, or a warning that should stay until they act. If the message can vanish on its own, that is a Sonner.

Scroll to load preview...

Looking for a neobrutalism version for shadcn?

Same alert, thicker borders. The NeoBrutalism alert is the kit if you want that look.

Usage

import { InfoIcon } from "lucide-react"
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"
<Alert>
  <InfoIcon />
  <AlertTitle>Heads up!</AlertTitle>
  <AlertDescription>
    You can add components with the CLI.
  </AlertDescription>
</Alert>

A direct svg child opens the icon column. role="alert" is already on the root.

Composition

Icon
AlertTitle
AlertDescription
AlertAction

Basic

Icon, title, description. The usual success or info row.

Scroll to load preview...

Destructive

variant="destructive" for a failed charge or a broken submit. Save amber for a warning.

Scroll to load preview...

Action

AlertAction pins a Button on the end. Enable, retry, dismiss.

Scroll to load preview...

Custom Colors

Class names on Alertbg-amber-50 dark:bg-amber-950 and matching text. The variants stay default.

Scroll to load preview...

RTL

Wrap with DirectionProvider and dir="rtl". The icon stays on the start edge.

Scroll to load preview...

API

Prop

Type

AlertTitle and AlertDescription take className. AlertAction is the end slot for a button.

Notes

Stay for a reason

If they can miss it, use a Sonner. An alert stays until the next render removes it.

Write the title as the outcome: “Payment failed”, not “Error”.

With other components

Questions

Was this page helpful?

Sign in to leave feedback.