Sigil

Modal

A modal dialog.

While it is open and traps focus, it is marked modal and the rest of the page is hidden from assistive technology.

GUITUIRuns in the browsermodal

Preview

Modal, Open, light themeModal, Open, dark theme

Usage example

fn modal_demo(open: Signal<bool>) -> NodeBuilder {    container()        .layout(LayoutStyle::flex_column().fill_width().height(268.0))        .child(text("Page behind the modal").nowrap())        .child(            modal(open)                .title("Confirm action")                .child(text("This modal is mounted at the root.").nowrap())                .actions(button("Cancel"), button("Confirm").primary()),        )}
fn modal_demo(  open: Signal<bool>,) -> NodeBuilder {  container()        .layout(LayoutStyle::flex_column().fill_width().height(268.0))        .child(text("Page behind the modal").nowrap())        .child(            modal(open)                .title("Confirm action")                .child(text("This modal is mounted at the root.").nowrap())                .actions(button("Cancel"), button("Confirm").primary()),        )}

States

All 2 captured states, each drawn by the window host and by the terminal host.

  • Modal, Default, light themeModal, Default, dark theme
    Default
  • Modal, Open, light themeModal, Open, dark theme
    Open

API

NameSignaturePurpose
modalfn modal(show: Signal<bool>) -> ModalBuilderA modal dialog. While it is open and traps focus, it is marked modal and the rest of the page is hidden from assistive technology.
ModalBuilder`struct ModalBuilder`; `close_button(bool)`; `ModalBuilder::new(Signal<bool>)`, `title(text)`, `child(impl IntoNode)`, `footer(impl IntoNode)`, `actions(cancel, confirm)`, `side(Side)`, `escape_closes(bool)`, `dismiss_on_backdrop(bool)`, `trap(bool)`; width with `WidgetLayoutExt::width`Builder of a modal or sheet. A titled dialog shows a close button that sets show to false; close_button(false) removes it. Children scroll in a body between the title and the footer, so the title and actions stay visible when the dialog reaches its maximum height. footer adds one node to the footer; actions(cancel, confirm) adds two. Escape closes the dialog by default. A click on the backdrop closes a sheet but not a modal, unless dismiss_on_backdrop changes it. trap(false) lets focus leave the dialog.