Skip to content

shadcn.io is an independent project built on shadcn/ui

Free

Standard with Title, Description and Action Alert for React

A neutral alert with the title Success, a saved-changes sentence, and View Details plus Dismiss. No icon, no tint, and the buttons are not connected.

The title Success, a saved-changes sentence, and View Details plus Dismiss. No icon and no tint. The buttons are not connected.

Use it when a neutral update needs a sentence and an optional next step. If they must choose before moving on, use an Alert Dialog. In React, Base UI does not dismiss it.

Preview

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.
Use email insteadNo credit card

Anatomy

Alert anatomy: root, icon, title, description, action

Usage

<Alert className="max-w-lg">
  <AlertTitle>Success</AlertTitle>
  <AlertDescription>
    Your changes have been saved successfully.
  </AlertDescription>
  <AlertAction className="flex gap-2">
    <Button size="xs">View Details</Button>
    <Button size="xs" variant="outline">
      Dismiss
    </Button>
  </AlertAction>
</Alert>

FAQ

When should I use fully-featured standard alerts?

When a neutral message needs an explanation and the reader may act on it: a finished export with a link to the file, a change with a link to the details. Drop the parts you don't need.

How do I create hierarchy without color theming?

With weight and order. AlertTitle is heavier than the muted AlertDescription, and the default button is filled while Dismiss is outlined, so the reader's eye goes to the title, then the main action.

Should buttons stack or stay inline with content?

Inline, at the end of the title row in AlertAction, as here. The description wraps underneath, so the buttons don't steal its width. If the labels get long, move them below the description.

How long should descriptions be in fully-featured alerts?

A sentence or two. With a title and two buttons the alert is already busy; more text belongs on the page View Details opens.

When should I use alerts vs dialogs for important messages?

Use an alert when the reader can keep working and act later. Use a dialog, or an Alert Dialog for confirmations, when they must decide before going on. An alert never blocks the page.

How should fully-featured standard alerts adapt for mobile?

They need no breakpoints: the buttons stay at the end of the title row and the description wraps underneath. Keep the title short so it fits beside both buttons on a narrow screen.

API Reference

Alert

No extra props in this demo. The rest is on the Alert page.

Button

Sets size="xs" and variant="outline". The rest is on the Button page.