Alert Dialog

A modal dialog that interrupts the user with important content and expects a response.

Anatomy

AlertDialog do |a|
a.trigger
a.content do
a.header do
a.title
a.description
end
a.footer do
a.cancel
a.action
end
end
end

API Reference

AlertDialog

NameTypeDefault
open:booleanfalse
Controls whether the dialog is initially open when rendered. When true, the dialog will be visible on page load.
attributeskeyword arguments

AlertDialog#trigger

NameTypeDefault
as_child:booleanfalse
When true, merges the trigger functionality with the child element instead of wrapping it in a div.
attributeskeyword arguments

AlertDialog#content

NameType
attributeskeyword arguments

AlertDialog#header

NameType
attributeskeyword arguments

AlertDialog#title

NameType
attributeskeyword arguments

AlertDialog#description

NameType
attributeskeyword arguments
NameType
attributeskeyword arguments

AlertDialog#cancel

NameTypeDefault
variant:symbol:outline
Button style variant. Options: :default | :destructive | :outline | :secondary | :ghost | :link
size:symbol:default
Button size. Options: :default | :sm | :lg | icon.
attributeskeyword arguments

AlertDialog#action

NameTypeDefault
variant:symbol:default
Button style variant. Options: :default | :destructive | :outline | :secondary | :ghost | :link.
size:symbol:default
Button size. Options: :default :sm | :lg | :icon.
as_child:booleanfalse
When true, merges the action functionality with the child element instead of rendering a button.
attributeskeyword arguments

AlertDialog#action_to

Rails button_to helper that submits a form.

NameTypeDefault
namestringnil
The button text or form URL (depending on usage pattern).
optionshashnil
Rails button_to options hash.
html_optionshashnil
HTML attributes. Also supports variant: and size: for button styling.

Keyboard Interactions

KeyDescription
SpaceOpens/closes the dialog.
EnterOpens/closes the dialog.
TabMoves focus to the next focusable element.
Shift+TabMoves focus to the previous focusable element.
EscCloses the dialog and moves focus to trigger.

Examples