Alert

An inline notice on a soft tinted surface. It tells people about something that affects the page they are on — a failed sync, a trial ending, a successful payment.

StableSource
New version available
Reload the page to get the latest features.

Import

tsx
import { Alert } from "@merid/react";

Examples

Tones

Each tone brings its own tint, text colour and icon.

Heads up
Maintenance is scheduled for Sunday 02:00 UTC.
Payment received
Your invoice has been marked as paid.

With an action

action is a trailing slot for a button or a dismiss IconButton. Dismissal is up to you: remove the alert from your state.

2 members are waiting for approval.

Without icon or live region

icon={null} hides the icon; any node replaces it. live="off" renders a plain note with no role.

Plain note without an icon or live region.

API reference

Renders a div; the ref and other div attributes are forwarded (the native title attribute is replaced by the title prop).

PropTypeDefaultDescription
tone"info" | "success" | "warning" | "danger""info"Colour tone and default icon.
titleReactNode–Medium-weight first line.
iconReactNode | null–Leading icon. Defaults to a tone glyph; null hides it.
actionReactNode–Trailing slot, e.g. an action button or dismiss IconButton.
live"polite" | "assertive" | "off"–Live-region behaviour. Defaults to polite for info/success and assertive for warning/danger.
childrenReactNode–Body text.

Styling

HookValues
.mrd-alertRoot
.mrd-alert__iconIcon slot
.mrd-alert__content, __title, __bodyText column
.mrd-alert__actionTrailing action slot
data-toneinfo · success · warning · danger

Component variables: --mrd-alert-bg and --mrd-alert-fg, set per tone to the matching -soft and -strong tokens.

css
.billing .mrd-alert[data-tone="info"] {
  --mrd-alert-bg: var(--mrd-tray);
  --mrd-alert-fg: var(--mrd-ink);
}

Accessibility

  • polite renders role="status", assertive renders role="alert". Live regions only announce content that changes after they mount, so render the alert when the event happens rather than toggling hidden.
  • Use live="off" for static notes present on page load, so screen readers do not interrupt.
  • The icon is decorative; the title and body carry the meaning, so do not rely on colour alone.

Guidelines

Do

Say what happened and what to do next in one or two sentences: “Sync failed. Check your connection.”

Avoid

Stack several alerts at the top of a page, or use danger for anything that is not an error.

Do

Use an Alert for messages tied to the current page that should stay visible.

Avoid

Use it for short-lived confirmations — those are a Toast.

  • Toast — transient notifications.
  • AlertDialog — confirmations that need an answer.
  • Badge — compact status labels.