Skip to main content
Alert component preview (light)
  • Location: sabo/src/components/ui/alert.tsx

When to use

  • Display inline status inside a page (success message, non-blocking warning, error summary).
  • Prefer Dialog for blocking confirmations and Toast for transient notifications.

Usage

sabo/src/components/ui/alert.tsx
import { Alert, AlertTitle, AlertDescription } from "@/components/ui/alert";
import { CircleAlertIcon, CheckCircleIcon } from "lucide-react";

export function Example() {
  return (
    <div className="space-y-3">
      <Alert>
        <CheckCircleIcon />
        <AlertTitle>Saved</AlertTitle>
        <AlertDescription>Your changes were saved successfully.</AlertDescription>
      </Alert>

      <Alert variant="destructive">
        <CircleAlertIcon />
        <AlertTitle>Failed to save</AlertTitle>
        <AlertDescription>Check your connection and try again.</AlertDescription>
      </Alert>
    </div>
  );
}

Key props

variant
string
default:"default"
default | destructive — toggles error styling.

Styling tip

  • Place an icon as the first child to enable the compact two‑column layout.
  • Keep titles short; put details in AlertDescription.

Accessibility

  • Uses role=“alert”. Ensure plain text content is readable by screen readers.