Dialogs

DialogControl

A movable, resizable window with a default button, plus message boxes and prompts you can await.

Overview

DialogControl is a window: a title bar with a close icon, a body, an optional footer. It drags by its title bar, resizes from eight handles, and is modal (page dimmed and blocked) or non-modal (page stays live). Enter can fire a default button, Escape closes, and a right-click on the title bar opens a Win32-style system menu. CssClass="fx-dialog-classic" gives it the classic frame for migrated VB6 forms.

MessageBoxControl and InputDialogControl are built on it, and IDialogService wraps both so any component can await a confirm, alert or prompt in place of the browser's own.

Examples

#Non-modal window

IsModal="false" leaves the page live. Width, height and position bind two ways, so a drag or resize reports back. ShowWindowIcon adds the icon that opens the system menu.

Example
Razor
C#
480px × 240px, centred

#Message box, prompt and the dialog service

IDialogService replaces window.confirm, alert and prompt: inject it anywhere and await the answer. A page can also own a MessageBoxControl and call ShowAsync for an icon, the .NET look, or a confirmation checkbox.

Example
Razor
C#

Documentation

DialogControl parameters

ParameterTypeDefaultDescription
VisibleboolfalseShown or not. Two-way with @bind-Visible; closing sets it false.
Headerstring?nullTitle-bar text; also the accessible name.
ChildContentRenderFragment?—Body.
FooterContentRenderFragment?nullFooter, right-aligned flex row. Rendered only when set.
Width / Heightstring?nullCSS sizes. Two-way: a resize reports the new values through WidthChanged / HeightChanged.
PositionDialogPosition?nullOffset from centre after a drag. Two-way with @bind-Position.
IsModalbooltruetrue dims and blocks the page; false leaves it live.
ShowCloseIconbooltrueThe ✕ in the title bar.
CloseOnEscapebooltrueEscape requests close.
OnEscapeEventCallback—When set, Escape runs this instead of closing. For dialogs whose close commits.
OnEnterEventCallback—Default button. A plain Enter anywhere in the dialog runs it after the focused control has handled the key; buttons, links, editors, grids and open dropdowns keep Enter.
CloseOnCtrlEnterboolfalseCtrl+Enter requests close.
CloseOnOverlayClickboolfalseA click on the dimmed backdrop requests close.
OnClose / ClosedEventCallback—Both run on every close request (✕, Escape, Alt+F4, system menu), in that order, then Visible goes false.
DraggablebooltrueTitle bar drags the window.
ResizablebooltrueEight resize handles.
MinResizeWidth / MinResizeHeightdouble320 / 160Resize floor in pixels.
MaxResizeWidth / MaxResizeHeightdouble0Resize ceiling in pixels; 0 means none.
ShowSystemMenubooltrueRight-click on the title bar opens the Move / Close menu.
ShowWindowIconboolfalseIcon at the left of the title bar that opens the same menu.
AutoFocusbooltrueFocus the first focusable control on open.
AriaLabel / AriaDescribedBystring?nullAccessible name when there is no header; id of a description.
CssClassstring?nullExtra classes on the window; fx-dialog-classic switches the frame.

IDialogService

MethodInputsReturnsDescription
ConfirmAsync()message
title
Task<bool>Yes / No box; true for Yes.
ConfirmCancelAsync()message
title
Task<MessageBoxResult>Yes / No / Cancel box.
AlertAsync()message
title
TaskOK box.
PromptAsync()message
title
defaultValue
Task<string?>Single-line input; null when cancelled.
()setupRegister DialogService and IDialogService as scoped; render one DialogHostControl in the layout. Without a host the calls return false, Cancel or null.

MessageBoxControl parameters

ParameterTypeDefaultDescription
VisibleboolfalseTwo-way; ShowAsync sets it for you.
Title / Messagestring"Message" / nullTitle bar and body text.
ButtonsMessageBoxButtonsOkWhich buttons to show.
IconCssstring?nullKeyword warning, info, error, question or none; any other value is used as a CSS class. The VB6 look shows the question icon by default on boxes with more than OK.
LookMessageBoxLookVB6VB6 classic frame or DotNet.
RequiredConfirmationTextstring?nullAdds a checkbox with this label; the primary button stays disabled until it is ticked.
DraggablebooltrueTitle bar drags the box.
CloseOnOverlayClickboolfalseBackdrop click closes.
OnResultEventCallback<MessageBoxResult>—Fires with the chosen button.
CssClassstring?nullExtra classes on the box.

InputDialogControl parameters

ParameterTypeDefaultDescription
VisibleboolfalseTwo-way; ShowAsync sets it for you.
Title / Promptstring"Input" / nullTitle bar and the label above the box.
InputValuestring""Current text.
Placeholder / InputType / MaxLengthstringnull / "text" / 256Passed to the text box.
OnResultEventCallback<string?>—Fires with the text, or null on cancel.
CssClassstring?nullExtra classes on the dialog.

Methods

MethodInputsReturnsDescription
MessageBoxControl.ShowAsync()message
title
buttons
icon
look
requiredConfirmationText
Task<MessageBoxResult>Shows the box and completes with the chosen button. All but message optional; icon takes the same keywords as IconCss.
InputDialogControl.ShowAsync()prompt
title
defaultValue
Task<string?>Shows the prompt; null when cancelled.
MultiLineEditControl.ShowAsync()initial
title
maxLength
prompt
Task<string?>Multi-line text prompt; null when cancelled.
DefaultButtonScope.ConsumeEnter()—voidCascaded by a dialog with OnEnter. A control calls it to keep one Enter for itself.
DefaultButtonScope.Defer()taskvoidThe default button waits for this task before deciding.

Enums: MessageBoxButtons Ok, OkCancel, YesNo, YesNoCancel · MessageBoxResult Ok, Cancel, Yes, No · MessageBoxLook VB6, DotNet · DialogPosition(X, Y) is the offset from centre in CSS pixels.

CSS classes

ClassEffect
fx-dialog-overlay · .fx-dialog-overlay-nonmodalFixed full-screen layer, 35% black and centred; non-modal makes it transparent and lets clicks through.
fx-dialog · .fx-dialog-classicThe window: white, rounded, shadow, 320px minimum, 90vw / 90vh maximum. Classic: grey, square 28px title bar, MS Sans Serif.
fx-dialog-header · fx-dialog-title · fx-dialog-close · fx-dialog-window-iconTitle bar parts. The ✕ turns red on hover.
fx-dialog-body · fx-dialog-footerBody with 16px padding; footer with a top border, right-aligned.
fx-dialog-btnFooter button styling that any button can take.
fx-dialog-resize-n … fx-dialog-resize-nwThe eight invisible resize handles.
fx-dialog-system-menuThe Win32-style menu.
fx-msgbox · .fx-msgbox-vb6 · .fx-msgbox-dotnetMessage box frame in each look.

CSS variables

VariableFallbackPurpose
--fx-dialog-bg#fffWindow, body and footer background.
--fx-border-radius8pxCorner radius.
--fx-dialog-border / --fx-dialog-border-colornoneWindow border.
--fx-dialog-shadow0 6px 24px rgba(0,0,0,.2)Window shadow.
--fx-dialog-header-bg / --fx-dialog-header-colortransparent / inheritTitle bar.
--fx-border-color#e0e0e0Header and footer dividers.
--fx-text-colorinheritBody text.
--fx-zoom1Scales the classic frame, close icon and system menu.

Keyboard and accessibility

  • The dialog has role="dialog", aria-modal when modal, and is labelled by Header or AriaLabel; AriaDescribedBy points at a description.
  • AutoFocus moves focus to the first focusable control on open; focus returns to the opener on close.
  • Escape closes, or runs OnEscape when set. Alt+F4 closes. Ctrl+Enter closes when CloseOnCtrlEnter is on. Enter fires OnEnter unless the focused control keeps the key.
  • The system menu (right-click on the title bar, or the window icon) offers Move and Close; Restore, Size, Minimize and Maximize are listed but disabled.
  • Message box: Escape closes, Enter picks the default button, Arrow keys and Tab move between the buttons.
  • The dialog imports the library's own dialog-control.js for focus capture and restore, Escape and Ctrl+Enter capture, and size measurement. No third-party script.
An unhandled error has occurred. Reload 🗙

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.