Browse documentation

Modal and dialog

Focus attention on a decision or a temporary task.

Import

Load the optional component layer before using the examples below.

Ruby
require "zaniah/ui"

Basic dialog

Keep the title concise and include an obvious way to finish or close.

Rendered example
A dark-theme dialog with title and content over a dimmed page.
Rendered by Zaniah's headless backend.
Ruby
Zaniah::UI::Dialog.new(
  Zaniah::UI::Label.new("Changes will be saved."),
  title: "Confirm changes")

API summary

Constructor options and behaviors are drawn from the component reference.

ComponentConstructor and methodsVariants or behavior
Modal, Dialog(content, title:, open:, close_on_scrim:, width:)focus trap, scrim, Esc

Accessibility

Modal dialogs trap focus, close with Escape, and restore focus to the previous control.

ComponentSemantic role
Modal, Dialogdialog/modal