Embossed UI

Search documentation

Search for a page or component.

Alert

Displays a callout for user attention.

import { InfoIcon } from "lucide-react"

import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"

export function AlertDemo() {
  return (
    <Alert>
      <InfoIcon />
      <AlertTitle>Sync runs every hour</AlertTitle>
      <AlertDescription>
        Products, orders and customers update automatically. You can also sync
        now from the store settings.
      </AlertDescription>
    </Alert>
  )
}

Installation

pnpm dlx shadcn@latest add https://ui.ikramhasan.com/r/alert.json

Usage

import {
  Alert,
  AlertAction,
  AlertDescription,
  AlertTitle,
} from "@/components/ui/alert"
<Alert>
  <InfoIcon />
  <AlertTitle>Heads up!</AlertTitle>
  <AlertDescription>
    You can add components and dependencies to your app using the cli.
  </AlertDescription>
  <AlertAction>
    <Button variant="outline">Enable</Button>
  </AlertAction>
</Alert>

Examples

Title only

import { PlugIcon } from "lucide-react"

import { Alert, AlertTitle } from "@/components/ui/alert"

export function AlertTitleOnly() {
  return (
    <Alert>
      <PlugIcon />
      <AlertTitle>Shopify is connected</AlertTitle>
    </Alert>
  )
}

Destructive

import { CircleAlertIcon } from "lucide-react"

import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"

export function AlertDestructive() {
  return (
    <Alert variant="destructive">
      <CircleAlertIcon />
      <AlertTitle>Sync failed</AlertTitle>
      <AlertDescription>
        We couldn&apos;t reach your store. Check that the app still has access,
        then <a href="#alert">try again</a>.
      </AlertDescription>
    </Alert>
  )
}

With action

import { InfoIcon, XIcon } from "lucide-react"

import {
  Alert,
  AlertAction,
  AlertDescription,
  AlertTitle,
} from "@/components/ui/alert"
import { Button } from "@/components/ui/button"

export function AlertWithAction() {
  return (
    <div className="flex flex-wrap items-center gap-2">
      <Alert>
        <InfoIcon />
        <AlertTitle>A new version is available</AlertTitle>
        <AlertDescription>Reload to get the latest changes.</AlertDescription>
        <AlertAction>
          <Button size="sm" variant="secondary">
            Reload
          </Button>
        </AlertAction>
      </Alert>
      <Alert>
        <AlertTitle>Your trial ends in 14 days</AlertTitle>
        <AlertAction>
          <Button size="icon-sm" variant="ghost" aria-label="Dismiss">
            <XIcon />
          </Button>
        </AlertAction>
      </Alert>
    </div>
  )
}

Without icon

import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"

export function AlertWithoutIcon() {
  return (
    <Alert>
      <AlertTitle>Heads up</AlertTitle>
      <AlertDescription>
        Changes to permissions take effect the next time the app syncs.
      </AlertDescription>
    </Alert>
  )
}

API Reference

Alert

The Alert component displays a callout for user attention.

PropTypeDefault
variant"default" | "destructive""default"

AlertTitle

The AlertTitle component displays the title of the alert.

PropTypeDefault
classNamestring-

AlertDescription

The AlertDescription component displays the description or content of the alert.

PropTypeDefault
classNamestring-

AlertAction

The AlertAction component displays an action element (like a button) positioned absolutely in the top-right corner of the alert.

PropTypeDefault
classNamestring-