Widgets / Modal
Modal
A centered box over a translucent scrim that fades the screen behind it.
Signature
Modal.modal
(backdropStyle: Style)
(borderStyle: Style)
(titleStyle: Style)
(width: int) (height: int)
(title: string)
(body: LayoutNode<'msg>)
: LayoutNode<'msg> Parameters
| parameter | type | what it is |
|---|---|---|
backdropStyle | Style | Tints the scrim that fades the screen behind the box, and fills the box interior; its Background is the fade target (Style.Default → dim toward black). |
width / height | int | The centered box size, in cells. |
title | string | Shown in the top row. |
body | LayoutNode<'msg> | The modal contents (one node; flow several through a Stack). |
Notes
Layer the modal over your base tree with LayoutNode.Overlay, gated on your model. The surround is a translucent scrim (the base shows through, dimmed) while the box itself stays opaque. The modal consumes nothing on its own — your update decides what Enter/Esc do while it is open. Make its buttons clickable with Focusable.region + withMouseRegion.
Example
LayoutNode.Overlay(Rect.Create(0, 0, 0, 0),
[ baseTree
Modal.modal Style.Default theme.border theme.title 44 9 "Confirm"
(Text.text "Apply 3 changes?" theme.fg) ])