0.1.0-rc.2

Alert

Alerts surface time-sensitive status without blocking the interface. Use them for session warnings, sync failures, or confirmations that do not warrant a modal.

Try it

Usage

Compose RuiAlert with RuiAlertIcon and short text for layout="inline", or RuiAlertTitle and RuiAlertDescription for layout="banner". Banner layouts omit the icon. RuiAlert owns the role="alert" surface; the host handles dismiss.

import { RuiAlert, RuiAlertIcon } from '@ecopages/radiant-ui/alert';
 
<RuiAlert variant="warning" layout="inline">
	<RuiAlertIcon variant="warning" />
	<span>Your session will expire in 5 minutes.</span>
</RuiAlert>

Inject or reveal an alert when the status becomes relevant. Copy that is always on the page should not use role="alert".

Theming

Alert tones use semantic status roles from the active theme, not Tailwind palette steps (blue-500, emerald-100, …). Each variant maps to a role family:

variantSemantic roleTypical utilities on .rui-alert--*
infoinfobg-info-container, text-on-info-container, border-info/30
successsuccessbg-success-container, text-on-success-container
warningwarningbg-warning-container, text-on-warning-container
errorerror (destructive)bg-error-container, text-on-error-container

Banner layouts paint the left accent rail with the role accent (bg-info, bg-warning, …). Brand color packs remap all roles for light and dark mode.

Override at the theme layer (tokens/presets/colors/*.css), not in component CSS. Toasts and other notification UI should reuse the same info / warning / success / error families.

Why a custom element?

<rui-alert> is justified when the alert can dismiss itself: it emits rui-close and removes the host from the DOM without re-building the composed light-DOM surface. The RuiAlert view owns role="alert", BEM classes, and the dismiss button markup; the CE owns dismiss behavior and event delegation.

For static, non-dismissible copy that is always visible, prefer plain markup without role="alert"; see Usage above.

Match severity to variant

Reserve error for blocking problems the user must address. Use warning for recoverable risk, success for completed operations, and info for neutral context.

<RuiAlert variant="warning" layout="inline">
	<RuiAlertIcon variant="warning" />
	<span>Disk space is running low.</span>
</RuiAlert>

Inline or banner layout

inline pairs RuiAlertIcon with a short message for compact status inside forms or page flow. banner spans the full width of a region with RuiAlertTitle and RuiAlertDescription.

import { RuiAlert, RuiAlertDescription, RuiAlertTitle } from '@ecopages/radiant-ui/alert';
 
<RuiAlert variant="info" layout="banner">
	<RuiAlertTitle>Documentation preview</RuiAlertTitle>
	<RuiAlertDescription>
		<p>This release includes breaking changes to the routing API.</p>
	</RuiAlertDescription>
</RuiAlert>

Dismissible alerts

Set dismissible when the user can clear the message. The host emits rui-close and then removes itself from the DOM.

<RuiAlert variant="warning" layout="inline" dismissible>
	<RuiAlertIcon variant="warning" />
	<span>Your session will expire in 5 minutes.</span>
</RuiAlert>

Accessibility

Follows the Alert pattern.

  • The view renders an inner surface with role="alert" so screen readers announce the message when it appears.
  • For inline alerts, pair RuiAlertIcon with text; do not rely on color or the icon alone to convey severity. The default icon is decorative (aria-hidden="true").
  • For banner alerts, use RuiAlertTitle for the headline and RuiAlertDescription for supporting detail.
  • Prefer alerts for interruptions that do not require an immediate response. Use a dialog when the user must decide before continuing.
  • When dismissible, the close control is a labeled button (close-label, default Dismiss).

API

Attributes

AttributeTypeDefaultDescription
variantinfo · success · warning · errorinfoVisual tone.
layoutinline · bannerinlineCompact row vs full-width advisory.
dismissiblebooleanfalseShow dismiss control; enables dismiss().
close-labelstringDismissAccessible name for the dismiss control.

Slots

SlotDescription
(default)Content inside the role="alert" region. inline: RuiAlertIcon + text. banner: RuiAlertTitle + RuiAlertDescription.

Events

EventDetailDescription
rui-close{ reason: 'dismiss' }Fired when the alert is dismissed; the host is then removed.

CSS classes

Public BEM classes on the light-DOM surface (documented via @cssclass on the JSX view helpers):

ClassDescription
.rui-alertRoot surface inside the host (role="alert").
.rui-alert--infoInfo tone (default).
.rui-alert--successSuccess tone.
.rui-alert--warningWarning tone.
.rui-alert--errorError tone.
.rui-alert--inlineCompact row layout (icon + text).
.rui-alert--bannerFull-width advisory with left accent rail.
.rui-alert--dismissibleLayout adjustments for the dismiss control.
.rui-alert__iconIcon wrapper (RuiAlertIcon, inline only).
.rui-alert__titleBanner headline (RuiAlertTitle).
.rui-alert__descriptionBanner body (RuiAlertDescription).
.rui-alert__closeDismiss button when dismissible is set.

Theme roles (per variant)

VariantCSS variables consumed
info--info, --info-container, --on-info-container
success--success, --success-container, --on-success-container
warning--warning, --warning-container, --on-warning-container
error--error, --error-container, --on-error-container

error is the destructive status role (same family as destructive buttons).