Alert
Alert - Phlex implementation
Examples
Default
A callout component for displaying important information.
Heads up!
You can add components to your app using the CLI.
<%= render "ui/alert" do %>
<%= render "ui/alert/title" do %>Heads up!<% end %>
<%= render "ui/alert/description" do %>You can add components to your app using the CLI.<% end %>
<% end %>Heads up!
You can add components to your app using the CLI.
<%= render UI::Alert.new do %>
<%= render UI::AlertTitle.new { "Heads up!" } %>
<%= render UI::AlertDescription.new { "You can add components to your app using the CLI." } %>
<% end %>Heads up!
You can add components to your app using the CLI.
<%= render UI::AlertComponent.new do %>
<%= render(UI::AlertTitleComponent.new) { "Heads up!" } %>
<%= render(UI::AlertDescriptionComponent.new) { "You can add components to your app using the CLI." } %>
<% end %>Destructive
Use the destructive variant to indicate an error or warning.
Error
Your session has expired. Please log in again.
<%= render "ui/alert", variant: :destructive do %>
<%= render "ui/alert/title" do %>Error<% end %>
<%= render "ui/alert/description" do %>Your session has expired. Please log in again.<% end %>
<% end %>Error
Your session has expired. Please log in again.
<%= render UI::Alert.new(variant: :destructive) do %>
<%= render UI::AlertTitle.new { "Error" } %>
<%= render UI::AlertDescription.new { "Your session has expired. Please log in again." } %>
<% end %>Error
Your session has expired. Please log in again.
<%= render UI::AlertComponent.new(variant: :destructive) do %>
<%= render(UI::AlertTitleComponent.new) { "Error" } %>
<%= render(UI::AlertDescriptionComponent.new) { "Your session has expired. Please log in again." } %>
<% end %>Features
- Custom styling with Tailwind classes
API Reference
Alert
A callout component for displaying important information to users.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| variant | Symbol | :default | Visual style variant |
Description
Description text for an alert component.
Title
Title text for an alert component.
Accessibility
Adheres to theAlert WAI-ARIA design pattern
Implements the WAI-ARIA Alert pattern with proper roles, states, and keyboard navigation.
ARIA Attributes
- role="alert"