Alert
Alert for a useful, keyboard-friendly product interface.
Make it yours.
Install the editable source and its dependencies into your React + Tailwind project.
Scroll horizontally for long lines
pnpm dlx shadcn@4.0.8 add http://localhost:3000/r/alert.jsonUse it
Scroll horizontally for long lines
"use client";
import { Alert } from "@/components/jez-ui/ui/alert";
export default function Example() {
return (
<>
<Alert title="Everything is up to date.">
Your changes have been saved on this device.
</Alert>
</>
);
}
Compose your own
These styled parts are included in the same install. Use children to build your layout; add className only when you want an override.
Scroll horizontally for long lines
import { Alert, AlertTitle, AlertDescription, AlertAction } from "@/components/jez-ui/ui/alert";Props & types
Scroll horizontally for long lines
Omit<React.ComponentProps<"div">, "title"> & {
title?: React.ReactNode;
variant?: "info" | "error" | "success";
}Source
View 2 source files
registry/ui/alert.tsx
Scroll horizontally for long lines
"use client";
import * as React from "react";
import { cn } from "./utils";
export function Alert({
title,
children,
variant = "info",
className,
...props
}: Omit<React.ComponentProps<"div">, "title"> & {
title?: React.ReactNode;
variant?: "info" | "error" | "success";
}) {
return (
<div
role={variant === "error" ? "alert" : "status"}
className={cn(
"rounded-xl border border-border p-4",
variant === "error" && "border-danger text-danger",
className,
)}
{...props}
>
{title !== undefined ? (
<>
<AlertTitle>{title}</AlertTitle>
<AlertDescription>{children}</AlertDescription>
</>
) : (
children
)}
</div>
);
}
export function AlertTitle({
className,
...props
}: React.ComponentProps<"h4">) {
return <h4 className={cn("text-sm font-medium", className)} {...props} />;
}
export function AlertDescription({
className,
...props
}: React.ComponentProps<"div">) {
return (
<div
className={cn(
"mt-1 text-sm leading-relaxed text-muted-foreground",
className,
)}
{...props}
/>
);
}
export function AlertAction({
className,
...props
}: React.ComponentProps<"div">) {
return (
<div className={cn("mt-4 flex flex-wrap gap-2", className)} {...props} />
);
}
registry/ui/utils.ts
Scroll horizontally for long lines
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...values: ClassValue[]) {
return twMerge(clsx(values));
}
Dependencies
clsx@2.1.1 · tailwind-merge@3.5.0
Accessibility & behaviour
Provide meaningful labels and preserve keyboard focus styles. Check contrast when customising theme colours.
Read the accessibility and performance guide →