TermUI.Widgets.Dialog (TermUI v0.2.0)
View SourceDialog widget for modal overlays.
Dialog appears centered over the application with a backdrop, traps focus, and handles Escape for cancellation. Use for confirmations, forms, and important messages.
Usage
Dialog.new(
title: "Confirm Delete",
content: delete_confirmation_content(),
buttons: [
%{id: :cancel, label: "Cancel"},
%{id: :confirm, label: "Delete", style: :danger}
],
on_close: fn -> dismiss_dialog() end,
on_confirm: fn button_id -> handle_action(button_id) end
)Features
- Centered display with customizable width/height
- Semi-transparent backdrop
- Focus trapping (Tab cycles within dialog)
- Escape to close
- Button navigation and selection
Keyboard Navigation
- Tab/Shift+Tab: Move between buttons
- Enter/Space: Activate focused button
- Escape: Close dialog
Summary
Functions
Sets focus to a specific button.
Gets the currently focused button ID.
Hides the dialog.
Creates new Dialog widget props.
Updates the dialog content.
Updates the dialog title.
Shows the dialog.
Gets whether the dialog is visible.
Functions
Sets focus to a specific button.
Gets the currently focused button ID.
Hides the dialog.
Creates new Dialog widget props.
Options
:title- Dialog title (required):content- Dialog body content (render node):buttons- List of button definitions:width- Dialog width (default: 40):on_close- Callback when dialog is closed:on_confirm- Callback when button is activated:closeable- Whether Escape closes dialog (default: true):title_style- Style for title bar:content_style- Style for content area:button_style- Style for buttons:focused_button_style- Style for focused button
Updates the dialog content.
Updates the dialog title.
Shows the dialog.
Gets whether the dialog is visible.