Alert
Display contextual feedback, status notices, and announcement banners.
Anatomy#
Usage#
Use Alert for inline feedback that stays in the page flow. Choose Toast for
transient notifications and BaseDialog for feedback that must block the page. Alert
sets role="alert" with aria-live="assertive" for the warning and error types, and
role="status" with aria-live="polite" for the rest.
Type and variant#
type selects the semantic status: default, info, success, warning, and error. The
info, success, warning, and error types render a matching status icon; default renders
none. variant selects the surface treatment: subtle (default), soft, outline, and solid.
Description layout#
Pass description for a supporting line below the title. With a description, the root uses larger
padding and the title turns bold. children render after the title and description.
Dismissal#
Set closable to render a dismiss button. Clicking it closes the alert, plays the exit animation,
and removes the alert from the DOM. Use open with onOpenChange to control visibility, or
defaultOpen to start closed. onOpenChange fires only for user dismissal, and onExitComplete
fires after the alert leaves the DOM. Override the button’s accessible label (Close alert) with
translations={{ close: '...' }}.
Examples#
Show status across every type#
Render one alert per type to compare their colors and status icons.
Add a supporting description#
Pass description to explain the title with a second line.
Offer actions#
Put buttons in actions so the reader can respond from the alert.
Let the reader dismiss an alert#
Set closable for a dismiss button. Drive visibility with open and onOpenChange.
Span a banner across the page#
Set fullWidth to remove the side borders and corner radius for an edge-to-edge banner.
Replace or hide the icon#
Pass icon with an icon name or element to override the status icon. Pass icon={false} to hide it.
API Reference#
Attributes#
data-closedata-closeddata-expandeddata-full-widthdata-has-descriptiondata-typeProps#
Props for Alert. Renders a <div> element by default.