Alert

Calls out something the reader should know, inline with the page.

View as Markdown
<Alert>  <HugeiconsIcon icon={CheckmarkCircle02Icon} />  <AlertTitle>Payment successful</AlertTitle>  <AlertDescription>    Your payment of $29.99 has been processed. A receipt has been sent to your    email address.  </AlertDescription></Alert>

Installation

$ npx shadcn@latest add @constella/alert

Usage

import {  Alert,  AlertDescription,  AlertTitle,} from "@/components/primitives/alert";
<Alert>  <HugeiconsIcon icon={InformationCircleIcon} />  <AlertTitle>Heads up!</AlertTitle>  <AlertDescription>    You can add components and dependencies to your app using the CLI.  </AlertDescription></Alert>

Composition

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

Color

Use the color prop to color the icon. The title and description stay neutral.

ColorIcon color
successGreen
infoBlue
warningAmber
dangerRed
<Alert color="danger">  <HugeiconsIcon icon={AlertCircleIcon} />  <AlertTitle>Payment failed</AlertTitle></Alert>

Alert Title

An alert can be a title alone, a description alone, or skip the icon; the text takes the room that's left.

<Alert color="success">  <HugeiconsIcon icon={CheckmarkCircle02Icon} />  <AlertTitle>Your changes are live.</AlertTitle></Alert>

Alert Action

Use AlertAction for a button at the alert's end.

<Alert>  <AlertTitle>Dark mode is now available</AlertTitle>  <AlertAction>    <Button size="sm" variant="outline">      Enable    </Button>  </AlertAction></Alert>

API Reference

PartAdds
Alertcolor: "success", "info", "warning" or "danger"; role="alert"
AlertTitlerender, to make it a heading: render={<h3 />}

Every part takes sx, applied last, and renders a div. For render, see Base UI useRender.