Skip to content

Dialog ​

A modal dialog. Backdrop + centered content card + confirm / cancel buttons; it supports semantic types and backdrop dismiss.

Spec source: lh-ui-core/specs/dialog.json · Golden cases: lh-ui-core/cases/dialog.json (8 cases, translated into xUnit tests)

Basic usage ​

Declarative visibility: when Visible is false nothing is rendered; after confirm / cancel Close fires and the host sets Visible back to false accordingly.

9:41Dialog basics
Confirm deletion
This action cannot be undone. Delete this record?

HTML mock preview (Windows / WinUI 3 appearance), not an on-device render

csharp
var dialog = new LhDialog
{
    Title = "Confirm deletion",
    Content = "This action cannot be undone. Delete this record?",
    Type = LhDialogType.Danger,
    ConfirmText = "Confirm",
    CancelText = "Cancel",
};
dialog.Confirm += () => { /* Perform the deletion */ };
dialog.Close += () => dialog.Visible = false;

dialog.Visible = true;

Semantic types ​

Type decides the confirm button's type (color); the cancel button is always the default type.

9:41Dialog types
Notice
This is a primary-confirm dialog

HTML mock preview (Windows / WinUI 3 appearance), not an on-device render

API ​

Props ​

PropDescriptionTypeDefault
ConfirmFired on confirmevent Action—
CancelFired on cancelevent Action—
CloseFired after confirm / cancel or (when closable) on a backdrop tap; the host sets Visible to false accordinglyevent Action—
VisibleWhether the dialog is shown; nothing is rendered when falseboolfalse
TitleTitlestring""
ContentBody contentstring""
TypeSemantic type; decides the confirm button's type (color)LhDialogTypeDefault
ConfirmTextConfirm button text; the confirm button is hidden when emptystring"确认"
CancelTextCancel button text; the cancel button is hidden when emptystring"取消"
ClosableWhether tapping the backdrop area fires Closeboolfalse

LhDialogType ​

ValueConfirm button type
DefaultLhButtonType.Default
PrimaryLhButtonType.Primary
SuccessLhButtonType.Success
WarningLhButtonType.Warning
DangerLhButtonType.Danger
InfoLhButtonType.Info

Token Reference ​

TokenUsage
dialog.width / dialog.borderRadiusContent card width and corner radius
dialog.paddingHorizontal / paddingVerticalContent card paddings
dialog.titleFontSize / contentFontSizeTitle and body font sizes
dialog.gapSpacing between title / content / buttons
color.background.defaultContent card background color
color.background.overlayBackdrop color
color.text.primary / color.text.regularTitle / body color
zIndex.modal / zIndex.modalBackdropContent card / backdrop elevation
shadow.baseContent card shadow

Golden Case Reference ​

How the 8 assertions of cases/dialog.json map to xUnit tests (tests/LhDialogTests.cs):

case idAssertionLocal test
confirm-emits-onconfirmConfirm fires onConfirmConfirm_Emits_OnConfirm
cancel-emits-oncancelCancel fires onCancelCancel_Emits_OnCancel
confirm-also-emits-oncloseConfirm also fires onCloseConfirm_Also_Emits_OnClose
closable-overlay-emits-oncloseWhen closable, a backdrop tap fires onCloseClosable_Overlay_Emits_OnClose
not-closable-blocks-overlay-closeWhen not closable, the backdrop does not closeNot_Closable_Blocks_Overlay_Close
hidden-not-renderedNothing is rendered when invisibleHidden_Not_Rendered
title-renders-textTitle and body render with the font-size tokensTitle_Renders_Text
danger-type-uses-danger-tokenThe danger type consumes the danger color tokenDanger_Type_Uses_Danger_Token

Plus dark-mode suites: Dark_Colors_Come_From_Dark_Tokens / Dimensions_Are_Identical_In_Dark_Mode. Run: cd lh-ui-windows && dotnet test.

lh-ui native bloodline · Windows (C# + WinUI 3)