Skip to content

Button ​

A basic action button. It triggers an immediate action and supports type, size, loading, disabled, icon, and a Chinese-style pattern background.

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

Types ​

Six types determine the background and text color.

9:41Button types

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

csharp
var button = new LhButton
{
    Type = LhButtonType.Primary,
    Text = "Primary button",
};
button.Click += OnButtonClick;

Sizes ​

Three sizes map to the button.height / paddingHorizontal / fontSize / iconSize tokens.

9:41Button sizes

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

States ​

Neither disabled nor loading triggers Click; when both are set, disabled wins (golden case disabled-precedes-loading).

9:41Button states

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

Icon and pattern background ​

Icon names resolve against the local icon system (LhButtonTokens.IconFor, currently supporting search / refresh / check / close; unregistered names draw nothing). The pattern background consumes the color.decoration token as a 45° hatching overlay.

9:41Icons & patterns

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

Light and dark themes ​

Toggle the site theme in the top-right corner and the button colors inside the simulator phone frame change with it; on a real device, switch via LhTheme.Apply(true).

9:41Dark buttons

HTML mock preview (Windows / WinUI 3 appearance), not an on-device render; light/dark values are all taken from the core token snapshot

API ​

Props ​

PropDescriptionTypeDefault
ClickTap callback; not triggered when Disabled or Loading is trueevent Action—
TypeButton type; determines the background and text colorLhButtonTypeDefault
SizeButton size; maps to the size tokensLhButtonSizeMedium
DisabledWhether the button is disabledboolfalse
LoadingWhether the button is loading (shows an indicator and does not fire Click)boolfalse
IconIcon name (resolved by the local icon system)string?null
BgPatternWhether to draw the Chinese-style background patternboolfalse
TextButton text content (the spec's default slot)string""

LhButtonType ​

ValueBackgroundText color
Defaultcolor.background.defaultcolor.text.primary
Primarycolor.primary.defaultcolor.onPrimary
Successcolor.success.defaultcolor.onPrimary
Warningcolor.warning.defaultcolor.onPrimary
Dangercolor.danger.defaultcolor.onPrimary
Infocolor.info.defaultcolor.onPrimary

LhButtonSize ​

ValueheightpaddingHorizontalfontSizeiconSize
Smallbutton.height.small (32epx)button.paddingHorizontal.small (16epx)button.fontSize.small (13)button.iconSize.small (16)
Mediumbutton.height.medium (40epx)button.paddingHorizontal.medium (20epx)button.fontSize.medium (14)button.iconSize.medium (18)
Largebutton.height.large (48epx)button.paddingHorizontal.large (24epx)button.fontSize.large (16)button.iconSize.large (20)

The disabled state overrides: background color.disabled.bg, text color.disabled.text, border color.disabled.border.

Token Reference ​

Tokens consumed by the button (aligned one-to-one with the tokenRefs of specs/button.json):

TokenUsage
button.height.{small,medium,large}Three heights
button.paddingHorizontal.{small,medium,large}Three horizontal paddings
button.fontSize.{small,medium,large}Three font sizes
button.iconSize.{small,medium,large}Three icon sizes
button.borderRadius / button.borderWidthCorner radius (follows radius.base) and border width
button.fontWeightFont weight (follows typography.fontWeight.primary; mapped to FontWeights on this end)
color.primary.default / color.onPrimaryPrimary type background / text
color.{success,warning,danger,info}.defaultSemantic type backgrounds
color.background.default / color.text.primary / color.border.baseDefault type background / text / border
color.disabled.{bg,text,border}The three disabled colors
color.decorationPattern color
spacing.xsSpacing between icon and text
typography.fontFamilyChinese-style serif font stack

Golden Case Reference ​

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

case idAssertionLocal test
click-emits-onclickThe gate passes (interactive)Enabled_Button_Is_Interactive
disabled-blocks-clickThe disabled state is not interactiveDisabled_Is_Not_Interactive
loading-blocks-clickThe loading state is not interactiveLoading_Is_Not_Interactive
disabled-precedes-loadingDisabled wins, with the disabled styleDisabled_Precedes_Loading
default-type-renders-textThe default type uses a neutral background / textDefault_Type_Uses_Neutral_Tokens
primary-type-uses-primary-tokensThe primary type consumes the primary tokensPrimary_Type_Uses_Primary_Tokens
small-size-uses-small-tokensSmall consumes the small size tokensSmall_Size_Uses_Small_Tokens
bgpattern-uses-decoration-tokenThe pattern background consumes the decoration colorBgPattern_Uses_Decoration_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)