Skip to the content

Notification

Notification shows a short status message without blocking the page. Render it inline (type="block"), as a full-width page banner (type="page"), or as a stacked toast through useNotification(). Inline and banner notifications are controlled: you hide them with visible={false}.
Feedback & Loading@apollion-dsi/core/containers/notification45.9 kB gzip

When to use

Use when
  • You report the result of an action: saved, failed, needs attention.
  • The message must coexist with the current flow instead of interrupting it.
  • Feedback arrives asynchronously; add autoClose so the toast dismisses itself.
Avoid when
  • A single form field is invalid — use the field's own error message.
  • The user must respond before continuing — use Modal.

Usage

Notification title

Complementary message detailing the notice.

const [visible, setVisible] = useState(true);

<Notification
  visible={visible}
  onDismiss={() => setVisible(false)}
  variant="primary"
  icon={<Icon icon={cog} />}
  title="Notification title"
  message="Complementary message"
/>;

The close button (shown by default; closable={false} hides it) and autoClose only call onDismiss.

Variants

variant sets the palette: primary (default), success, warning, danger.

Success

Operation completed

Warning

Attention required

action takes a node or ({ close }) => node; its color follows variant. close is your onDismiss, so call it yourself — the action does not close the notification.

Notification with action

The action renders on the right.

<Notification
  title="Session expiring"
  message="Your session ends in one minute."
  onDismiss={hide}
  action={({ close }) => (
    <Button
      size="small"
      text="Renew"
      onClick={() => {
        renew();
        close();
      }}
    />
  )}
/>

type="page" portals a full-bleed banner to the top or bottom edge (pagePosition, default bottom). Pass pageOffset (the app-bar height) so a top banner sits under the chrome instead of covering it.

loading

Toasts

ApollionProvider mounts the toast provider, so any component below it can call useNotification().

import { useNotification } from '@apollion-dsi/core/containers/notification';

function SaveButton() {
  const { showNotification } = useNotification();
  const notify = () =>
    showNotification({ title: 'Saved', message: 'Your changes are live.', variant: 'success', autoClose: 5 });

  return <Button text="Save" onClick={notify} />;
}
  • Toasts stack in the bottom-right corner. At most three stay open: a fourth removes the oldest.
  • autoClose is in seconds and draws a progress bar that pauses on hover. Without it, the toast stays until closed.
  • A toast closed by its button, autoClose or close() animates out before it leaves the queue.

Accessibility

  • danger renders role="alert" (aria-live="assertive"); the other variants render role="status" (polite).
  • aria-atomic="true" reads the title and message as one announcement.
  • closeLabel names the close button (default 'Fechar notificação'). Localize it, and make it specific when several notifications share the screen.
  • Do not make an autoClose toast the only route to critical information or to an action.

Properties

Also accepts the layout props.

See also