Notification
Displays a short, important message in a way that attracts the user's attention without interrupting what they are doing.
Notification offers three usage modes:
type="block"(default): renders inline in the React tree. Useful for alerts inside sections, forms and cards.type="page": renders in a portal pinned to the top or bottom of the page (controlled bypagePosition). Slides from its own edge via thesheet/sheet-topmotion presets (pure CSS, ADR-027).- Stacked toasts: the
useNotification()hook exposed by theNotificationsProviderfires floating notifications in the bottom-right corner.
When to use
| ✅ Use when… | 🚫 Avoid when… |
|---|---|
|
|
Basic example
Notification title
Complementary message detailing the notice.
<Notification
closable
type="block"
variant="primary"
icon={<Icon icon={cog} />}
title="Notification title"
message="Complementary message"
/>Actions
action accepts a ReactNode or a function ({ close }) => ReactNode.
The action color is forced to the notification's variant.
Notification with action
Click Confirm to trigger the action and close.
<Notification
closable
type="block"
variant="primary"
icon={<Icon icon={cog} />}
title="Title"
message="Message"
action={({ close }) => (
<Button
onClick={() => {
confirm();
close();
}}
size="small"
text="Confirm"
/>
)}
/>Variants
Notification offers four color variants: primary (default),
success, warning, danger.
Primary
Default message
Success
Operation completed
Warning
Attention required
Danger
Something went wrong
<Notification variant="primary" title="Primary" message="Default message" />
<Notification variant="success" title="Success" message="Operation completed" />
<Notification variant="warning" title="Warning" message="Attention required" />
<Notification variant="danger" title="Danger" message="Something went wrong" />Types
<Notification type="block" /* renders inline */ />
<Notification type="page" pagePosition="top" pageOffset={56} /* full-bleed banner under a 56px app bar */ />
<Notification type="page" pagePosition="bottom" /* strip at the page foot */ />type="page" is a full-bleed banner: 100% wide, square, one border on
the inner edge only (bottom when on top, top when at the bottom), fixed to
the viewport edge. Pass pageOffset (the app-bar height) so a top banner
sits under the chrome instead of covering it. type="block" stays the
rounded, four-side-bordered card.
loading
Toasts
Use the useNotification() hook to display floating toasts. The
NotificationsProvider is already mounted by the
ThemeProvider, so any component below it can fire
toasts:
import { useNotification } from '@apollion-dsi/core/containers/notification';
import { cog } from '@apollion-dsi/core/icons';
function ToastDemo() {
const { showNotification } = useNotification();
return (
<Button
text="Notify"
onClick={() =>
showNotification({
title: 'Done!',
message: 'Operation completed',
variant: 'success',
autoClose: 5,
})
}
/>
);
}The active queue is limited to 3 toasts — the fourth automatically removes
the oldest one. autoClose in seconds displays a progress bar
that pauses on hover.
When action should dismiss the notification, call the close argument
yourself — the notification does not close automatically after the action
fires.
Accessibility
The notification is a live region: it appears outside the focus flow and, without this, it would not exist for screen reader users.
| Variant | Role | Behavior |
|---|---|---|
danger | alert | aria-live="assertive" — interrupts what is being read |
| others | status | aria-live="polite" — waits for the next pause |
aria-atomic="true" makes the title and message be read as a single unit. The close button gets its name via closeLabel; with multiple notifications on screen, differentiate them (closeLabel="Close payment notice").
autoClosedisappears on its own. Do not make it the only route to critical information or to an action — screen reader users or slow navigators may miss it.
Properties
Prop | Type | Default | Description |
|---|---|---|---|
action | ReactNode | ((p: { close: () => void; }) => ReactNode) | null | Button/action to the right of the content. Accepts a `ReactNode` or a
function `(p: { close }) => ReactNode`. The action color is forced to
the notification's `variant`. |
alignContent | "center" | "start" | "end" | "between" | "around" | "evenly" | "stretch" | — | Packing of wrapped lines / grid tracks on the block axis. |
autoClose | number | null | Time in seconds for auto-dismissal. When provided, displays a
progress bar that pauses on hover. |
closable | boolean | true | Shows a close button in the top-right corner. |
closeLabel | string | Fechar notificação | Accessible name of the close button. Override to localize or to
describe what is being closed when there are multiple notifications. |
containment | string | — | Containment marker for the `cq` channel: emits
`container-type` (+ `container-name` when the string form carries one,
e.g. `'inline-size card'`). Apply on the immediate wrapper of the
adapting component — NEVER on page-level shells. |
cq | Partial<Record<ContainerSizeTypes, Partial<Omit<Partial<{ area: string; padding: string | number; margin: string | number; isHidden: boolean; truncate: boolean; pageShell: boolean; ... 14 more ...; transform: string; }>, "containment"> & Partial<...> & SizeFactoryProps & Partial<...>>>> | — | Container-relative **layout** styles per `theme.containerSizes` key. |
enableBreakpoint | "xs" | "xl" | "sm" | "md" | "lg" | — | Forces a breakpoint's prop set to apply regardless of viewport (stories/previews). |
icon | ReactNode | null | Icon displayed to the left of the content. |
ignoreResponsive | boolean | — | Fully disables the responsive factory (tests / fixed snapshots). |
justifyItems | "center" | "start" | "end" | "stretch" | — | Grid containers: inline alignment of every item in its cell. |
link | { text: string; href?: string; to?: any; } | undefined | — | Optional link displayed below the message. Opens in a new tab. |
message | ReactNode | ((p: { close: () => void; }) => ReactNode) | null | Main message. Accepts a `ReactNode` or a function
`(p: { close }) => ReactNode` — useful for including an inline
"close" button. |
motion | "none" | "fade" | "scale" | "slide-up" | "slide-down" | "slide-left" | "slide-right" | "collapse" | "sheet" | "sheet-top" | "drawer-left" | "drawer-right" | — | Semantic motion preset. Enter animates on mount via
`@starting-style`; exit expects the `data-state="closing"` attribute
(see `useExitTransition`). Durations/easings resolve from the
`--apollion-motion-*` vars with the theme literal as fallback, so
`prefers-reduced-motion` zeroes them centrally.
@example ```tsx
<Flex motion="slide-up">Toast body</Flex>
``` |
onDismiss | (() => void) | — | Callback fired when the notification is dismissed. |
pageOffset | string | number | 0 | Distance from the viewport edge when `type="page"` — the app-bar height
for `pagePosition="top"` (so the banner sits under the chrome instead
of covering it), a footer height for `"bottom"`. Number = px. |
pagePosition | "top" | "bottom" | 'bottom' | Position on the page when `type="page"`. |
pageShell | boolean | — | Centers the element and caps the width at `theme.layout.pageMaxWidth`.
The page shell of a classic centered layout. |
placeItems | "center" | "start" | "end" | "stretch" | — | Grid containers: `place-items` shorthand (block + inline). |
title | string | — | Title displayed prominently. |
transform | string | — | CSS `transform` value (e.g. `translate(-50%, -33px)`). Never leaks
to the DOM as an attribute. |
type | "block" | "page" | block | Rendering type. |
variant | "primary" | "success" | "warning" | "danger" | primary | Color variant. |
viewportMedias | Partial<Record<keyof BreakPoint<any>, Partial<Omit<Partial<{ area: string; padding: string | number; margin: string | number; isHidden: boolean; truncate: boolean; pageShell: boolean; container: boolean; ... 13 more ...; transform: string; }>, "containment"> & Partial<...> & SizeFactoryProps & Partial<...>>>> | unde... | — | Viewport-driven **layout** styles per `theme.breakpoints` key. |
visible | boolean | true | Controls whether the notification is visible. |
Besides the props above, every component accepts the layout props (spacing, color, flex/grid, size, border) — not repeated here.
See also
- Storybook story: Components / Notification
- Provider and hook:
Notification.context.