Dokumentation (english)
Components: Shadcn UI

Alert

Understand the design system and contribute to it

Component preview

The live preview for UI components is handled by components/atoms/codedocs/ComponentPreview.tsx. Use it directly inside MDX whenever you want a playground-style embed. Provide componentProps to set default values and propOptions to surface toggle-able props next to the preview.

Preview

Prop reference

Auto-generated from the component source

Alert

  • className
  • variant

React.ComponentProps<"div"> & VariantProps<typeof alertVariants>

AlertDescription

  • className

React.ComponentProps<"div">

AlertTitle

  • className

React.ComponentProps<"div">

Code
// owner: Sona
"use client";

import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
import { CheckCircle2, Info, ShieldAlert } from "lucide-react";

export default function AlertExample() {
  return (
    <div className="flex flex-col gap-4">
      <Alert className="gap-2">
        <CheckCircle2 className="text-emerald-500 size-4" />
        <div>
          <AlertTitle>Deployment successful</AlertTitle>
          <AlertDescription>
            The production cluster has been updated and is live.
          </AlertDescription>
        </div>
      </Alert>
      <Alert variant="destructive" className="gap-2">
        <ShieldAlert className="size-4" />
        <div>
          <AlertTitle>Database locked</AlertTitle>
          <AlertDescription>
            Rotate your credentials or contact an administrator.
          </AlertDescription>
        </div>
      </Alert>
      <Alert className="gap-2" variant="default">
        <Info className="size-4" />
        <div>
          <AlertTitle>Heads up</AlertTitle>
          <AlertDescription>
            Maintenance is scheduled for this weekend.
          </AlertDescription>
        </div>
      </Alert>
    </div>
  );
}

On this page


Command Palette

Search for a command to run...

Schnellzugriffe
STRG + KSuche
STRG + DNachtmodus / Tagmodus
STRG + LSprache ändern

Software-Details
Kompiliert vor 15 Tagen
Release: v4.0.0-production
Buildnummer: master@6fbd7b5
Historie: 13 Items