ConsoleForge 0.3.0
Elm-architecture TUI framework for .NET 8
Loading...
Searching...
No Matches
ConsoleForge.Widgets.Modal Class Referencesealed

A centered dialog overlay widget. More...

Inheritance diagram for ConsoleForge.Widgets.Modal:

Public Member Functions

Region ComputeBodyRegion (Region outer)
 Returns the region allocated to Body within the centered dialog box.
 Modal ()
 Object-initializer constructor; all properties default.
 Modal (string title="", IWidget? body=null, int dialogWidth=60, int dialogHeight=16, bool showBackdrop=false, Style? style=null)
 Positional constructor for inline usage.
void Render (IRenderContext ctx)
 Optionally fills the region with a backdrop, then renders a centered bordered dialog box containing Body.

Properties

Style BackdropStyle [get]
 Style used for the backdrop fill when ShowBackdrop is true.
IWidgetBody [get]
 Content widget rendered inside the dialog box.
int DialogHeight = 16 [get]
 Height of the dialog box in rows.
int DialogWidth = 60 [get]
 Width of the dialog box in columns.
SizeConstraint Height = SizeConstraint.Flex(1) [get]
 Height constraint of the outer region (not the dialog box).
bool ShowBackdrop = false [get]
 When true, fills the entire region with BackdropStyle spaces before rendering the dialog box, creating a dark-overlay effect.
Style Style = Style.Default.Border(Borders.Rounded) [get]
 Visual style for the dialog border and title. Inherits theme border style when unset.
string Title = "" [get]
 Title text rendered in the dialog's top border edge.
SizeConstraint Width = SizeConstraint.Flex(1) [get]
 Width constraint of the outer region (not the dialog box).

Detailed Description

A centered dialog overlay widget.

Renders a bordered box on top of whatever is already in the cell buffer (paint-over, no viewport capture).

Compose with ZStack to show a modal on top of existing content:

new ZStack([
mainLayout,
isOpen ? new Modal("Confirm", body: confirmBody) : new TextBlock(""),
])
Modal()
Object-initializer constructor; all properties default.
Definition Modal.cs:81
A widget that renders a single string, wrapping at region width.
Definition TextBlock.cs:11
A layered widget that renders its children back-to-front over the same region.
Definition ZStack.cs:24

FocusFocusManager traverses into Body automatically (Modal implements ISingleBodyWidget). The model is responsible for routing keyboard input to the modal when it is open.

Backdrop — When ShowBackdrop is true, the entire region is filled with BackdropStyle spaces before drawing the dialog box. This replaces background content with a dark overlay. When false (default), content behind the modal remains visible.

Constructor & Destructor Documentation

◆ Modal()

ConsoleForge.Widgets.Modal.Modal ( string title = "",
IWidget? body = null,
int dialogWidth = 60,
int dialogHeight = 16,
bool showBackdrop = false,
Style? style = null )

Positional constructor for inline usage.

Parameters
titleDialog title in the top border.
bodyContent widget inside the dialog.
dialogWidthDialog box width (columns). Default 60.
dialogHeightDialog box height (rows). Default 16.
showBackdropFill background with BackdropStyle before drawing.
styleOptional border/title style override.

Property Documentation

◆ BackdropStyle

Style ConsoleForge.Widgets.Modal.BackdropStyle
get
Initial value:
=
Style.Default.Background(Color.FromRgb(20, 20, 20)).Faint(true)
Style Style
Visual style for the dialog border and title. Inherits theme border style when unset.
Definition Modal.cs:46

Style used for the backdrop fill when ShowBackdrop is true.

Defaults to a dark background with faint text.

◆ DialogHeight

int ConsoleForge.Widgets.Modal.DialogHeight = 16
get

Height of the dialog box in rows.

Clamped to the available terminal height. Default 16.

◆ DialogWidth

int ConsoleForge.Widgets.Modal.DialogWidth = 60
get

Width of the dialog box in columns.

Clamped to the available terminal width. Default 60.

◆ Height

SizeConstraint ConsoleForge.Widgets.Modal.Height = SizeConstraint.Flex(1)
get

Height constraint of the outer region (not the dialog box).

Defaults to SizeConstraint.Flex so the widget fills the terminal.

Implements ConsoleForge.Layout.IWidget.

◆ ShowBackdrop

bool ConsoleForge.Widgets.Modal.ShowBackdrop = false
get

When true, fills the entire region with BackdropStyle spaces before rendering the dialog box, creating a dark-overlay effect.

Default false (background content remains visible).

◆ Width

SizeConstraint ConsoleForge.Widgets.Modal.Width = SizeConstraint.Flex(1)
get

Width constraint of the outer region (not the dialog box).

Defaults to SizeConstraint.Flex so the widget fills the terminal.

Implements ConsoleForge.Layout.IWidget.


The documentation for this class was generated from the following file:
  • src/ConsoleForge/Widgets/Modal.cs