GitHub

Alert

Inline callout surface for important context, warnings, and success confirmation inside the page layout.

AccessibleDark Mode5 Variants

Install

$npx react-principles add alert
01

Theme Preview

Light
Dark
03

Code Snippet

src/ui/Alert.tsx
import { Alert } from "@/ui/Alert";

<Alert variant="warning">
  <Alert.Title>Unsaved changes</Alert.Title>
  <Alert.Description>You have pending edits that are not published yet.</Alert.Description>
  <Alert.Footer>
    <Alert.Action>Review changes</Alert.Action>
  </Alert.Footer>
</Alert>
04

Copy-Paste (Single File)

Alert.tsx
import type { ButtonHTMLAttributes, HTMLAttributes } from "react";
import { cn } from "@/lib/utils";

export type AlertVariant = "default" | "success" | "warning" | "error" | "info";

export interface AlertProps extends HTMLAttributes<HTMLDivElement> {
  variant?: AlertVariant;
}
05

Props

PropTypeDefaultDescription
variant"default" | "success" | "warning" | "error" | "info""default"Changes the semantic styling for the alert surface.
classNamestringAdditional classes merged into the alert container.
react-principles