Browse documentation

Alerts

Show a persistent message that needs the user's attention.

Import

Load the optional component layer before using the examples below.

Ruby
require "zaniah/ui"

Example

Choose the variant that matches the message. An alert remains visible until dismissed or replaced by the application.

Rendered example
A success alert above a calendar in the Zaniah component gallery.
Rendered by Zaniah's headless backend.
Ruby
Zaniah::UI::Alert.new(
  "Export complete",
  message: "Your file is ready",
  variant: :success,
  dismissible: true
)

Live announcements

Set live: true only when a new message should be announced by assistive technology.

API summary

Constructor options and behaviors are drawn from the component reference.

ComponentConstructor and methodsVariants or behavior
Alert(title, message:, variant:, action:, dismissible:, live:); dismissinfo/success/warning/danger; persistent until dismissed

Accessibility

A live alert uses the alert role; otherwise the message is exposed as status.

ComponentSemantic role
Alertalert when live, otherwise status