Alert
Polished inline notices and toast updates for concise feedback.
Installation
npx shadcn@latest add @iconiq/alertProps
Alert
Root container for a single notice. Uses a compact grid layout with optional leading icon, compound title and description slots, legacy prop support, and inline or toast behavior.
childrenReactNodeiconReactNodetitleReactNodemessageReactNodeactionReactNodeappearance"default" | "destructive" | "warning"Default "default"
size"sm" | "md" | "lg" | "xl"Default "md"
widthstring | numberdismissiblebooleanDefault legacy: true; compound inline: false
variant"inline" | "toast"Default "inline"
position"top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right"timeoutnumberDefault legacy/toast: 5000; compound inline: 0
onDismiss() => voidUse size for preset widths or pass width for a custom max width. md defaults to 400px.
Every positioned alert snaps to a full-width top placement on small screens, then switches to the requested corner at the sm breakpoint.
Inline alerts use role="alert"; toast alerts use role="status" with aria-live="polite" and keep title and message linked with aria-labelledby and aria-describedby.
The alert keeps its own visible state internally when dismissal is enabled, so toast usage is designed for fire-and-forget notifications rather than parent-controlled open state.
Hovering or focusing the alert pauses auto-dismiss, which gives people more time to read and makes the close target less stressful to hit.
AlertTitle
Primary line for the compound alert API. Renders in the second grid column beside the optional icon.
childrenReactNodeRequired
classNamestringAlertDescription
Secondary line for the compound alert API. Renders beneath the title in the second grid column and links to the root with aria-describedby.
childrenReactNodeRequired
classNamestringMotion and lifecycle
Alert uses AnimatePresence for mount and exit, with separate variants for the container, icon, and text stack.
Entry uses long fluid easing on opacity, vertical drift, scale, and blur so the alert settles in rather than snapping.
Exit keeps the same direction with a softer, slightly slower fade so dismissal still feels continuous.
Child text and the icon only fade on exit, which keeps the container motion cohesive.
The timeout effect is cleared on cleanup, so unmounting or rerendering the alert does not leak timers.
When position is set, the component waits until after mount before calling createPortal to avoid touching document during server render.
Dismissal callbacks wait until the exit transition completes, so parent cleanup does not cut off the visual exit early.
Registry bundle
Install the exact registry entry shown on the right when you want the component file and its declared runtime dependencies together.
Dependencies: motion, class-variance-authority.
This page lives in the Components section, but the install itself is the shared Iconiq alert primitive rather than a Radix UI or Base UI wrapper.
The provider switch is shown for section consistency, but both Radix UI and Base UI options are disabled because Alert does not ship primitive-specific variants here.
The generated registry file is /r/alert.json.