GooseUI

Components

Alert

New

A callout for a message the user should notice: a saved form, a failed payment, a planned outage. Default and destructive variants; the icon is a slot, an <svg> as the first child or any node in icon. Server component, no JavaScript.

Preview

Changes saved
Your profile is up to date. It may take a minute to show everywhere.

Installation

npx shadcn@latest add @gooseui/alert
pnpm dlx shadcn@latest add @gooseui/alert
yarn dlx shadcn@latest add @gooseui/alert
bunx --bun shadcn@latest add @gooseui/alert

Usage

import { CircleCheck } from "lucide-react"
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"

export default function Example() {
  return (
    <Alert>
      <CircleCheck />
      <AlertTitle>Changes saved</AlertTitle>
      <AlertDescription>Your profile is up to date.</AlertDescription>
    </Alert>
  )
}

Examples

Destructive

For errors and actions that failed.

Payment failed
Your card was declined. Check the card details and try again.
<Alert variant="destructive">
  <TriangleAlert />
  <AlertTitle>Payment failed</AlertTitle>
  <AlertDescription>Your card was declined.</AlertDescription>
</Alert>

Without an icon

Without an icon the text takes the full width.

Planned maintenance
The dashboard will be read-only on Sunday from 02:00 to 03:00 UTC.
<Alert role="note">
  <AlertTitle>Planned maintenance</AlertTitle>
  <AlertDescription>…</AlertDescription>
</Alert>

Icon prop and role

icon puts any node in the icon column. Alert has role="alert", which screen readers announce at once; for calm, static messages pass role="status" or role="note".

Tip
Press Shift and scroll the wheel to scroll wide tables sideways.
<Alert role="note" icon={<Info className="text-primary" />}>
  <AlertTitle>Tip</AlertTitle>
  <AlertDescription>…</AlertDescription>
</Alert>

Props

PropTypeDefaultDescription
variant"default" | "destructive""default"Visual style
iconReact.ReactNode-Icon in the first column. An <svg> child works the same way
rolestring"alert"role="alert" by default; "status" or "note" for messages that should not interrupt
classNamestring-Additional CSS classes