Skip to content
Components

Alert

Alert for a useful, keyboard-friendly product interface.

Open ↗

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.json

Use 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></>;
}

Props & types

Scroll horizontally for long lines
React.HTMLAttributes<HTMLDivElement> & {
  title: string;
  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
}: React.HTMLAttributes<HTMLDivElement> & {
  title: string;
  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}
    >
      <p className="text-sm font-medium">{title}</p>
      <div className="mt-1 text-sm">{children}</div>
    </div>
  );
}

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 →