Alert
SM · 950B gzip budgetA static in-flow message, polite or assertive by tone.
- Category
- Feedback & status
- Budget
- sm, single-purpose control
- External runtime
- React / React DOM only
axe fixtureSSR rendersource scanbundle budget
Preview
Live fixtureHeads up
Informational message.
Try the component here. Locale-aware formatting and direction follow the selected language; example content and labels are not automatically translated. Overlay demos use interactive launchers.
Install
npx shadcn@latest add https://gear5-ui.vercel.app/r/alert.jsonCopies the source into your project. Pulls in 1 shared registry item: cn.
New here? Set up Tailwind and import aliases first →Source & props
Edit on GitHub ↗Prop types and inline documentation are included below. This is repository source; the installer rewrites shared imports for your project.
import { cn } from "../lib/cn";
export type AlertTone = "info" | "success" | "warning" | "danger";
const TONES: Record<AlertTone, string> = {
info: "border-blue-200 bg-blue-50 text-blue-900 dark:border-blue-900 dark:bg-blue-950/50 dark:text-blue-100",
success:
"border-green-200 bg-green-50 text-green-900 dark:border-green-900 dark:bg-green-950/50 dark:text-green-100",
warning:
"border-amber-200 bg-amber-50 text-amber-900 dark:border-amber-900 dark:bg-amber-950/50 dark:text-amber-100",
danger: "border-red-200 bg-red-50 text-red-900 dark:border-red-900 dark:bg-red-950/50 dark:text-red-100",
};
export interface AlertProps {
tone?: AlertTone;
title?: string;
children: React.ReactNode;
className?: string;
}
/**
* A static, in-flow message. `role="status"` for info/success — announced
* politely, since neither interrupts what the user is doing — and
* `role="alert"` for warning/danger, which are assertive by nature.
*/
export function Alert({ tone = "info", title, children, className }: AlertProps) {
const assertive = tone === "warning" || tone === "danger";
return (
<div
role={assertive ? "alert" : "status"}
className={cn("rounded-lg border p-4 text-start text-sm", TONES[tone], className)}
>
{title && <p className="mb-1 font-medium">{title}</p>}
<div>{children}</div>
</div>
);
}
What CI checks
Quality contract- Bundled, minified and gzipped against its tier budget
- Audited by axe in the state previewed above
- Rendered through react-dom/server with no browser globals
- Scanned for network calls, dangerous sinks, and unguarded animation