Mushilu-San UI

Search components

PlaygroundStorybookGitHub
Feedback

Alert

An inline message that tells the user about a success, warning, error or information on the page.

Selector: mui-alert

Import
import { Alert } from '@mushilu-san/ui/feedback';
PreviewCode

Loading example…

Overview

Alert shows a message in place, next to the content it relates to. variant sets the meaning: info, success, warning or danger.

warning and danger alerts are role="alert" (assertive), so they interrupt. info and success are role="status" (polite). Set dismissible to show a close button that emits dismissed.

When to use

  • Confirming a result on the page, such as "Changes saved".
  • Warning about a problem that affects the content nearby.

When not to use

  • A brief message that disappears on its own. Use a toast. Use Toast instead.
  • A decision the user must make before continuing. Use an alert dialog. Use Alert dialog instead.

Guidelines

Do

  • Say what happened and what to do next in the message.
  • Use the variant that matches the severity.

Don't

  • Do not stack several alerts on one page.
  • Do not use danger for a minor issue.

Accessibility

Roles and attributes

ElementRoleNotes
hoststatus or alertrole="alert" for warning and danger, otherwise role="status". aria-live follows the role.
dismiss buttonbuttonHas a visible close label.

Keyboard

KeysAction
TabShiftTabMoves focus to the dismiss button when dismissible is set.
  • Do not move focus to an alert when it appears. Screen readers announce it from the live region.

API

Alert

Selector: mui-alert

NameTypeDefaultDescription
variant'info' | 'danger' | 'success' | 'warning''info' Visual + semantic severity.
headingstring | undefined— Optional bold heading rendered above the projected body.
dismissiblebooleanfalse Show a dismiss button and enable Escape-to-dismiss. Accepts attribute presence, e.g. <… dismissible>.
NameTypeDescription
dismissedvoid Emitted when the user dismisses the alert (button or Escape).

CSS parts

  • ::part(body)
  • ::part(dismiss)
  • ::part(root)
  • ::part(title)

Tokens

  • --mui-color-success-subtle
  • --mui-color-warning-subtle
  • --mui-color-danger-subtle
  • --mui-color-primary-subtle
  • --mui-radius-md
  • --mui-color-focus-ring