avertra-ui
uialertsource: ok · hit
Alert
An alert component for displaying messages.
npx shadcn add "https://micomponents.micustomer.io/r/alert.json"free
No selection tags yet — empty means no evidence, not lack of support.
Files1 · source cached 10/9/2026, 10:17:13 PM
src/components/ui/alert.tsx
"use client";
import { cva } from "class-variance-authority";
import type { VariantProps } from "class-variance-authority";
import { forwardRef } from "react";
import type { HTMLAttributes } from "react";
import React from "react";
import { cn } from "@/stories/lib/utils";
const alertVariants = cva(
"relative w-full rounded px-4 py-3 text-sm [&>svg]:absolute [&>svg]:left-4 [&>svg]:text-foreground [&>svg~*]:pl-8",
{
variants: {
variant: {
info: "bg-info/5 border-info/20 [&>svg]:text-info",
success: " bg-success/5 border-success/30 [&>svg]:text-success",
warning: "bg-warning/5 border-warning/30 [&>svg]:text-warning",
error: "bg-error/5 border-error/30 [&>svg]:text-error",
white: "bg-black/5 border-black/30 [&>svg]:text-foreground",
},
},
defaultVariants: {
variant: "info",
},
},
);
const Alert = forwardRef<
HTMLDivElement,
HTMLAttributes<HTMLDivElement> & VariantProps<typeof alertVariants>
>(({ className, variant, ...props }, ref) => (
<div
ref={ref}
role="alert"
className={cn(alertVariants({ variant }), className)}
{...props}
/>
));
Alert.displayName = "Alert";
const AlertTitle = forwardRef<
HTMLParagraphElement,
HTMLAttributes<HTMLHeadingElement>
>(({ className, ...props }, ref) => (
<h5
ref={ref}
className={cn("mb-1 font-medium leading-none tracking-tight", className)}
{...props}
/>
));
AlertTitle.displayName = "AlertTitle";
const AlertDescription = forwardRef<
HTMLParagraphElement,
HTMLAttributes<HTMLParagraphElement>
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn("text-sm [&_p]:leading-relaxed", className)}
{...props}
/>
));
AlertDescription.displayName = "AlertDescription";
export { Alert, AlertDescription, AlertTitle };