Components
Alert
BetaBeta — the props contract is close to final, but small breaking changes can still land.Inline status panel for callouts, errors, and notices.
Composition
Anatomy
- <Alert>
- <AlertTitle />
- <AlertDescription />
Dismissible
AlertAction takes its own column beside the title, so long text wraps before a dismiss button instead of running under it.
- <Alert>
- <AlertTitle />
- <AlertDescription />
- <AlertAction>
- <Button />
Installation
The Control UI source installs this component from src/registry/sources/control-ui/ui/alert.tsx.
npx shadcn@latest add https://control-ui.dev/r/alert.jsonRaw code
Primary installed source
"use client";
import { useRender } from "@base-ui/react/use-render";import type { ComponentProps, CSSProperties } from "react";import type { RenderProp } from "@/components/control-ui/control-props";import type { AlertKnobStyle } from "@/components/control-ui/knob-contracts/alert-knobs";import { cn } from "@/components/control-ui/lib/cn";
export const alertTones = ["neutral", "info", "success", "warning", "danger"] as const;
export type AlertTone = (typeof alertTones)[number];
export type AlertProps = Omit<ComponentProps<"div">, "style"> & { style?: CSSProperties & AlertKnobStyle } & { tone?: AlertTone };
export type AlertTitleProps = Omit<ComponentProps<"div">, "style"> & { render?: RenderProp<ComponentProps<"div">>; style?: CSSProperties & AlertKnobStyle;};
export type AlertDescriptionProps = Omit<ComponentProps<"div">, "style"> & { style?: CSSProperties & AlertKnobStyle };
export type AlertActionProps = Omit<ComponentProps<"div">, "style"> & { style?: CSSProperties & AlertKnobStyle };
export function Alert({ tone = "neutral", className, ...props }: AlertProps) { return ( <div role={tone === "danger" ? "alert" : "status"} data-control-ui="alert" data-control-family="alert" data-slot="root" data-surface="panel" data-tone={tone} className={cn("relative grid w-full items-start", className)} {...props} /> );}
export function AlertTitle({ render, className, ...props }: AlertTitleProps) { return useRender({ defaultTagName: "div", render, props: { ...props, "data-control-ui": "alert", "data-control-family": "alert", "data-slot": "title", className: cn("col-start-2 min-w-0", className), }, });}
export function AlertDescription({ className, ...props }: AlertDescriptionProps) { return ( <div data-control-ui="alert" data-control-family="alert" data-slot="description" className={cn("col-start-2 grid min-w-0 justify-items-start", className)} {...props} /> );}
export function AlertAction({ className, ...props }: AlertActionProps) { return ( <div data-control-ui="alert" data-control-family="alert" data-slot="action" className={cn("col-start-3 row-span-2 row-start-1 flex items-center gap-1 self-start", className)} {...props} /> );}
Knobs
Typed custom properties the recipe paints with. Set one on the root — style, a utility class, or a skin — and every slot inherits it.
| Knob | Syntax | Default |
|---|---|---|
--cui-alert-radius | <length-percentage> | var(--radius-panel) |
--cui-alert-background | <color> | var(--card) |
--cui-alert-border-color | <color> | var(--border) |
--cui-alert-shadow | * | none |
--cui-alert-foreground | <color> | var(--card-foreground) |
--cui-alert-description-foreground | <color> | var(--muted-foreground) |
--cui-alert-border-width | <length> | var(--control-rim-width) |
--cui-alert-padding | <length-percentage> | calc(var(--spacing) * 3) |
--cui-alert-padding-inline | <length-percentage> | calc(var(--spacing) * 4) |
--cui-alert-gap | <length-percentage> | calc(var(--spacing) * 0.5) |
--cui-alert-icon-gap | <length-percentage> | calc(var(--spacing) * 3) |
--cui-alert-icon-size | <length-percentage> | calc(var(--spacing) * 4) |
--cui-alert-font-size | <length-percentage> | var(--text-body) |
--cui-alert-description-gap | <length-percentage> | var(--spacing) |
--cui-alert-title-font-weight | <number> | var(--font-weight-medium) |