Notification
The toast card — compound parts (Root / Icon / Title / Description / ActionTrigger / CloseTrigger / CollapseTrigger) on one outline surface, tinted by `color`. Spawned imperatively through the Notifier.
Notification is the kit's toast card — the visual surface for transient, non-blocking feedback. You rarely render it directly: you spawn toasts imperatively through the Notifier (notify.success('Saved')), and its region renders a Notification for each live toast. This page documents the card itself — its compound parts and its styling axes — for the times you compose a custom toast body.
There is a single surface, an outline, and one styling axis: color (the palette, a data-color attribute resolved to the --c-* slot vars) tints its border, text and icon. Enter/exit and the height animations are driven by CSS (see the Notifier for the moving parts).
Anatomy
A toast body is a small compound. The header row holds the leading Icon, the Title, and the CloseTrigger (or, for a foldable card, the CollapseTrigger); the Description and the action row sit below, each revealed independently with a Collapse.
Code
<Notification.Root color="green">
<div className="flex flex-row gap-3">
<Notification.Icon><CircleCheck /></Notification.Icon>
<Notification.Title>Profile updated</Notification.Title>
<Notification.CloseTrigger />
</div>
<Notification.Description>Your changes are live across all 42 campuses.</Notification.Description>
<div className="mt-1 flex flex-wrap items-center gap-2">
<Notification.ActionTrigger>Undo</Notification.ActionTrigger>
</div>
</Notification.Root>The parts:
Notification.Root— the card. Takes acolor; forwards everything else to adiv(and supportsasChild).Notification.Icon— leading-glyph slot; inherits the card's text color and sizes any childsvgto match.Notification.Title/Notification.Description— the heading and the secondary line.Notification.ActionTrigger— a styled inline button for the action row (any node works; this is just the kit's button styling).Notification.CloseTrigger— the dismiss (×) button; renders a default icon unless you pass children.Notification.CollapseTrigger— the collapse chevron,CloseTrigger's counterpart; takes a requiredopenthat drives its label,aria-expandedand the chevron's rotation, and leaves the state itself to you. Renders a default chevron unless you pass children.
Every part above takes its own testId, rendered as data-testid on its own element — see Testing.
Surfaces
Every card is the same outline; only color changes. A status type maps onto a hue and a default leading icon — info is neutral, success green, warning orange, error red. Anything else is a custom color on the same surface. type and color are mutually exclusive — passing both is a type error:
Code
<Notification type="info" title="info" />
<Notification type="success" title="success" />
<Notification type="warning" title="warning" />
<Notification type="error" title="error" />
<Notification color="purple" icon={<Info />} title="purple" />Notification.Root stays a plain surface.Ready-made card
Composing the parts by hand is for bespoke bodies. For the common case, the bare Notification builds the whole card from props — a type or a color (never both), an optional icon, a title, and optional description and action. It's the same object shape the Notifier spawns, exported so you can drop a status card straight into a page — no notifier, no store.
It can also trade its close (×) button for a collapse toggle: set withCollapse and turn off withCloseButton (which takes precedence). A chevron then folds the description and action rows away, each animating its own height with a Collapse. Leave it uncontrolled with defaultOpen, or drive it with open / onOpenChange.
Code
<Notification
withCollapse
withCloseButton={false}
defaultOpen
type="success"
title="Profile updated"
description="Your changes are live across all 42 campuses."
action={<Notification.ActionTrigger>Undo</Notification.ActionTrigger>}
/>Prop
Type
Icons
icons replaces the card's default icons: one per status type (success, error, warning, info, and loading, a spinner by default), the close × (close), and the collapse chevron (collapse), which turns half a turn while the card is folded. A missing key keeps its default. A card's own icon still wins over its status icon, and null drops a status icon. Pass the same map to <Notifications icons> to change every toast. The compound CloseTrigger and CollapseTrigger parts take their icon as children. Your icons are drawn as given: add className={iconStroke} (from @42/ui-react) for the kit's 1.5px line.
Code
<Notification
type="success"
title="Profile updated"
icons={{ success: <BadgeCheck className={iconStroke} />, close: <X className={iconStroke} /> }}
/>
<Notification
type="error"
title="Upload failed"
description="The file is over 10 MB."
withCloseButton={false}
withCollapse
defaultOpen
icons={{ error: <OctagonX className={iconStroke} />, collapse: <ChevronsDown className={iconStroke} /> }}
/>API
Notification.Root — the card surface (the compound primitive). Accepts every div/Ark prop (asChild, id, style, …) plus:
Prop
Type
Accessibility
A toast the Notifier spawns is announced: the notifier makes each card a live region as it renders it (role="status", or role="alert" for an error).
A standalone Notification carries no role. Rendered with the page, it's content to read rather than news, and a live region there would only repeat itself. When you insert one in response to something that just happened, pass the role yourself (role="status", or role="alert" for a failure); it lands on the root:
{saved && <Notification type="success" title="Saved" role="status" />}Screen readers announce a status most reliably when it's in the page before its text changes, so for a card that comes and goes, keep it mounted and swap its content, or mount it inside a region that's already live.
To spawn these toasts imperatively — status presets, promises, updates, placement and stacking — see the Notifier.
Changelog
- #361
Swap any built-in icon through an
iconsmap —icons={{ asc, desc }}on DataTable,icons={{ show, hide }}on PasswordInput; a key you leave out keeps the kit's icon, and a part'schildrenstill win - #376
Alert's close label translates through
translations.closeTriggerLabel, and Notification's close and collapse labels read fromtranslations - #376
Toasts are announced — errors as
alert, others as politestatus— and auto-dismiss pauses while focus is in the stack - #398
Notifications mounted in a background tab hold their timers, so toasts no longer expire unseen
- #384
A callback
refis no longer detached and re-attached on every render
- #294
asChildis a compile error on the data forms ofAccordion,TabsandBreadcrumb, on the ready-madeNotificationand onAppShell.Sidebar(theirRootparts keep it)
- #279
Anchor the start and end placements to logical insets
- #213
Drop the
variantaxis for one outline surface tinted bycolor;typeandcolorare mutually exclusive
- #41
Floating surfaces take a brand tint
- #8
New toast
Notifications with a notifier:notify,notify.update, and a collapsible body
EmptyState
The block a list shows in place of its rows — an icon, a title, a muted description and the actions. DataTable's empty and error views are drawn with it.
Notifier
Spawn toast notifications imperatively from anywhere — success/error/warning/info/loading, actions, promises and in-place updates — with createNotifier. A custom toaster modelled on the overlays manager, animated in CSS.