Modal Dialog
Accessible modal dialogs with backdrop, focus trapping, and smooth animations. Available in default, alert, confirm, and prompt variants. Built with Stimulus and Tailwind CSS.
Default
General-purpose modal dialog with title, content, and close button
_modal.html.erb
████ ███████████████████████
████████████████████████████████████████████████
███████████████ █████
█████████████████████████████
█████████████
██████████████████
████ ████████ ███
████ ████████████████████████████
████████████████████████████████
████████████ ███████ ███████████████ ████████████████ ██████████████████████████
modal_controller.js
██████ █ ██████████ █ ████ ████████████████████
██████ ███████ █████ ███████ ██████████ █
██████ ███████ █ ████████████ ████████ █████████████ ██████████████
█████████ █
█████████ █ ████
██ ██████████ ███ ██████ █████ ██ ██ ███████ █████████ █████ ███ ███████ ██████
██ ███████████████████████████ █
modal_component.rb
█ ██████████████████████ ████
█████ ██████████████ █ ███████████████████
███████████ ██████
███ ██████████████████
██████ █ █████
███
███ ████
modal_controller.js
██████ █ ██████████ █ ████ ████████████████████
██████ ███████ █████ ███████ ██████████ █
██████ ███████ █ ████████████ ████████ █████████████ ██████████████
█████████ █
█████████ █ ████
██ ██████████ ███ ██████ █████ ██ ██ ███████ █████████ █████ ███ ███████ ██████
██ ███████████████████████████ █
Alert
Alert dialog with variant icon, message, and single OK button
_modal.html.erb
███ ███████ █████████ ██████ ███████ █████████ ██████████████ █████ ███
██
██████████████ █ █
█████ █ ████████ ████████████ █████████████████████ ██████████ ██████████████ ████████████████████ ██████████ ████████████ █████████████████ ████████████████ ████████████████████████ ████████████ █████████████ ███████████ █████████████████████████████ ██
████████ █ ████████ █████████████ ██████████████████████ ██████████ ███████████████ █████████████████████ ██████████ █████████████ ██████████████████ █████████████████ █████████████████████████ ████████████ █████████████ ███████████ ██████████████████████████████ ██
███████ █ ████████ ███████████ ████████████████████ ██████████ █████████████ ███████████████████ ██████████ ███████████ ████████████████ ███████████████ ███████████████████████ ████████████ █████████████ ███████████ ████████████████████████████ ██
████████ █ ████████ ███████████████ ████████████████████████ ██████████ █████████████████ ███████████████████████ ██████████ ███████████████ ████████████████████ ███████████████████ ███████████████████████████ ████████████ █████████████ ███████████ ████████████████████████████████ █
█
██████ █ ██████████████████████████████ ██ █████████████████████
██
modal_controller.js
██████ █ ██████████ █ ████ ████████████████████
██████ ███████ █████ ███████ ██████████ █
██████ ███████ █ ████████████ ████████ █████████████ ██████████████
█████████ █
█████████ █ ████
██ ██████████ ███ ██████ █████ ██ ██ ███████ █████████ █████ ███ ███████ ██████
██ ███████████████████████████ █
modal_alert_component.rb
█ ██████████████████████ ████
█████ ███████████████████ █ ███████████████████
███████████ █████████ ███████ █████████ ██████████████
████████ █ ███████ ███████ ██████ ███████████████
███ ███████████████████ ██████ ███████ █████████ ██████████████ █████
████████ █ █████████████████████████████████ █ ██████████████ █ █████
██████ █ █████
modal_alert_component.html.erb
████ ███████████████████████
████████████████████████████████████████████████
███████████████ █████
███████████████████████████████████
██████████████████
██████████████████
████ ████████ ███
████ ████████████████████████████
████████████ ███████ ███████████████ ████████████████ ██████████████████████████
modal_controller.js
██████ █ ██████████ █ ████ ████████████████████
██████ ███████ █████ ███████ ██████████ █
██████ ███████ █ ████████████ ████████ █████████████ ██████████████
█████████ █
█████████ █ ████
██ ██████████ ███ ██████ █████ ██ ██ ███████ █████████ █████ ███ ███████ ██████
██ ███████████████████████████ █
Confirm
Confirmation dialog with icon, message, and Cancel/Confirm buttons
_modal.html.erb
███ ███████ █████████ ██████ ███████ █████████ ██████████████ ██████████ █████████████ █████████ ███
██
██████████████ █ █
█████ █ ████████ ████████████ █████████████████████ ██████████ ██████████████ ████████████████████ ██████████ ████████████ █████████████████ ████████████████ ████████████████████████ ████████████ █████████████ ███████████ █████████████████████████████ ██
████████ █ ████████ █████████████ ██████████████████████ ██████████ ███████████████ █████████████████████ ██████████ █████████████ ██████████████████ █████████████████ █████████████████████████ ████████████ █████████████ ███████████ ██████████████████████████████ ██
███████ █ ████████ ███████████ ████████████████████ ██████████ █████████████ ███████████████████ ██████████ ███████████ ████████████████ ███████████████ ███████████████████████ ████████████ █████████████ ███████████ ████████████████████████████ ██
████████ █ ████████ ███████████████ ████████████████████████ ██████████ █████████████████ ███████████████████████ ██████████ ███████████████ ████████████████████ ███████████████████ ███████████████████████████ ████████████ █████████████ ███████████ ████████████████████████████████ █
█
██████ █ ██████████████████████████████ ██ █████████████████████
██
modal_controller.js
██████ █ ██████████ █ ████ ████████████████████
██████ ███████ █████ ███████ ██████████ █
██████ ███████ █ ████████████ ████████ █████████████ ██████████████
█████████ █
█████████ █ ████
██ ██████████ ███ ██████ █████ ██ ██ ███████ █████████ █████ ███ ███████ ██████
██ ███████████████████████████ █
modal_confirm_component.rb
█ ██████████████████████ ████
█████ █████████████████████ █ ███████████████████
███████████ █████████ ███████ █████████ ███████████████ █████████████
████████ █ ███████ ███████ ██████ ███████████████
███ ███████████████████ ██████ ███████ █████████ ██████████████ ██████████ █████████████ █████████
████████ █ █████████████████████████████████ █ ██████████████ █ █████
██████ █ █████
modal_confirm_component.html.erb
████ ███████████████████████
█████████████████████████████████████████████████
███████████████ █████
█████████████████████████████████████
██████████████████
██████████████████
████ ████████ ███
████ ████████████████████████████
████████████ ███████ ███████████████ ████████████████ ██████████████████████████
modal_controller.js
██████ █ ██████████ █ ████ ████████████████████
██████ ███████ █████ ███████ ██████████ █
██████ ███████ █ ████████████ ████████ █████████████ ██████████████
█████████ █
█████████ █ ████
██ ██████████ ███ ██████ █████ ██ ██ ███████ █████████ █████ ███ ███████ ██████
██ ███████████████████████████ █
Prompt
Prompt dialog with icon, message, input field, and Cancel/Submit buttons
_modal.html.erb
███ ███████ █████████ ██████ ███████ █████████ ████████████ ████ ██████████████████ ███ ████████████ ███ ██████████████ █████████ █████████████ █████████ ███
██
██████████████ █ █
█████ █ ████████ ████████████ █████████████████████ ██████████ ██████████████ ████████████████████ ██████████ ████████████ █████████████████ ████████████████ ████████████████████████ ████████████ █████████████ ███████████ █████████████████████████████ ██
████████ █ ████████ █████████████ ██████████████████████ ██████████ ███████████████ █████████████████████ ██████████ █████████████ ██████████████████ █████████████████ █████████████████████████ ████████████ █████████████ ███████████ ██████████████████████████████ ██
███████ █ ████████ ███████████ ████████████████████ ██████████ █████████████ ███████████████████ ██████████ ███████████ ████████████████ ███████████████ ███████████████████████ ████████████ █████████████ ███████████ ████████████████████████████ ██
████████ █ ████████ ███████████████ ████████████████████████ ██████████ █████████████████ ███████████████████████ ██████████ ███████████████ ████████████████████ ███████████████████ ███████████████████████████ ████████████ █████████████ ███████████ ████████████████████████████████ █
█
██████ █ ██████████████████████████████ ██ █████████████████████
██
modal_controller.js
██████ █ ██████████ █ ████ ████████████████████
██████ ███████ █████ ███████ ██████████ █
██████ ███████ █ ████████████ ████████ █████████████ ██████████████
█████████ █
█████████ █ ████
██ ██████████ ███ ██████ █████ ██ ██ ███████ █████████ █████ ███ ███████ ██████
██ ███████████████████████████ █
modal_prompt_component.html.erb
████ ███████████████████████
█████████████████████████████████████████████████
███████████████ █████
████████████████████████████████████
█████████████
██████████████████
████ ████████ ███
████ ████████████████████████████
████████████ ███████ ███████████████ ████████████████ ██████████████████████████
modal_prompt_component.rb
█ ██████████████████████ ████
█████ ████████████████████ █ ███████████████████
███████████ █████████ ███████ █████████ ███████████████ ██████████████
█████████████ ███████████████████ ████████████
████████ █ ███████ ███████ ██████ ███████████████
███ ███████████████████ ██████ ███████ █████████ ██████████████ █████████ █████████████ █████████
████████████ ████ ██████████████████ ███ ████████████ ███
modal_controller.js
██████ █ ██████████ █ ████ ████████████████████
██████ ███████ █████ ███████ ██████████ █
██████ ███████ █ ████████████ ████████ █████████████ ██████████████
█████████ █
█████████ █ ████
██ ██████████ ███ ██████ █████ ██ ██ ███████ █████████ █████ ███ ███████ ██████
██ ███████████████████████████ █
Changelog
- v2.0.0: Converted to multi-style with alert, confirm, and prompt variants
- v1.1.0: Added ViewComponent format support
- v1.0.0: Initial release with focus trap, backdrop click to close
Get Full Access
Unlock the source code for this component and all others. One-time payment for lifetime access.
Get Access Now