Skip to main content
PimentCSS v1.0.1, what's new
Home

Alerts

Inline alerts, dismiss controls, and dialog-style confirmations.

Inline alerts for persistent page feedback, plus a blocking alert dialog overlay for critical decisions. Styles live in scss/components/_alert.scss. General task dialogs use Modals; transient toasts use Snackbar; layout cards use Cards.

Semantic variants

Four semantic surfaces: alert--information, alert--success, alert--warning, alert--error. Pair with role="status" (information, success) or role="alert" (warning, error).

Information

Informational message for the user.

Success

The operation has completed successfully.

With or without icon

Add .alert--with-icon and an .alert__icon slot (decorative, aria-hidden="true"). Text-only alerts omit the icon column.

Information

Informational message for the user.

Success

The operation has completed successfully.

Dismissible alerts

Add .alert--dismissible and .alert__close. Wire with data-alerts-live (see Behavior) or your own handler that sets hidden on the root.

Information

Informational message for the user.

Success

The operation has completed successfully.

Auto-dismiss

Optional data-alert-auto-dismiss="6000" (milliseconds) removes the alert after a delay. Always keep a close button for users who need more time.

Success

The operation has completed successfully.

This alert auto-hides after 6 seconds. Use the close button to dismiss immediately.

Responsive layout

Alerts are fluid (width: 100%). In narrow columns, dismissible alerts with icons wrap the close control to preserve touch targets (44px).

Alert dialog (overlay)

Blocking overlay for critical messages: .alert-dialog + role="alertdialog", aria-modal="true", backdrop dismiss, Escape, and footer actions. Open with data-alert-dialog-open targeting the dialog id.

Behavior in your app

Copy docs-site/src/lib/alert-behavior.ts and call wireAllAlerts() after load. This site wires it from doc-client.ts for data-alerts-live and data-alert-dialog-live.

Class reference

Class / attributeDescription
.alertInline feedback block (fluid width)
.alert--with-iconIcon column + content
.alert--dismissibleClose button slot
.alert__closeDismiss control (44px target)
data-alerts-liveWire dismiss + auto-dismiss
data-alert-auto-dismissAuto-hide delay in ms
.alert-dialogFixed overlay root (hidden when closed)
data-alert-dialog-openOpens dialog by id
data-alert-dialog-closeCloses dialog

Customize (Sass)

  1. Alert spacing and dialog width

    Override tokens before importing PimentCSS.
    @use "pimentcss-design-system" with (
      $alert-icon-size: 1.25rem,
      $alert-dialog-max-width: 32rem
    );
  2. Rebuild CSS

    Run after editing _alert.scss.
    npm run build:css

Accessibility (RGAA / WCAG)

Alerts

  • Roles, role="alert" for urgent messages; role="status" for informational feedback.
  • Alert dialog, focus moves to the panel on open and returns to the trigger on close. For general modals with focus trap, see Modals.
  • Auto-dismiss, never rely on timing alone; always offer a close control.
  • Icons, decorative; meaning must be in the title and body text.

Next steps