Skip to content

Radio ​

A radio button. A ring plus an inner dot; the tap target covers the whole row. The component itself carries no group logic — the host maintains the radio group.

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

Basic usage ​

The host listens to Change and sets the other items of the same group to Checked = false — that is the radio group.

9:41Radio basics
青花瓷 (ceramic blue)
粉彩瓷 (famille rose)

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

csharp
var radio = new LhRadio
{
    Label = "青花瓷 (ceramic blue)",
    Value = "qinghua",
    Checked = true,
};
radio.Change += isChecked => { /* Fires only when unchecked and not disabled; the host maintains the group */ };

Sizes ​

Three sizes map to the radio.size.* ring-size tokens; the inner dot diameter = size × radio.dotScale.

9:41Radio sizes
Small
Medium
Large

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

States ​

When Disabled the radio does not respond to taps: the outer ring takes color.disabled.border and the dot takes color.disabled.text; tapping an already-checked radio does not fire Change.

9:41Radio states
Disabled unchecked
Disabled checked

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

API ​

Props ​

PropDescriptionTypeDefault
ChangeChecked-state callback; fires only when unchecked and not disabled (the payload is always true)event Action<bool>—
CheckedWhether the radio is checkedboolfalse
DisabledWhether the radio is disabled (does not respond to taps and renders the disabled style)boolfalse
LabelText label (drawn to the right of the ring)string""
ValueRadio value (the group identifier; the component itself carries no group logic)string""
SizeRing size; maps to the radio.size.* tokensLhRadioSizeMedium

LhRadioSize ​

ValueSize token
Smallradio.size.small (14epx)
Mediumradio.size.medium (16epx)
Largeradio.size.large (18epx)

Token Reference ​

TokenUsage
radio.size.{small,medium,large}Three ring sizes
radio.ringWidthOuter ring stroke width
radio.dotScaleInner dot diameter ratio (size × dotScale)
radio.gapSpacing between the ring and the label
color.primary.defaultChecked ring and dot color
color.border.baseUnchecked ring color
color.disabled.{border,text}Disabled ring / dot
color.text.{primary,disabled}Label text color
typography.fontSize.base / fontFamilyLabel font size and font stack

Golden Case Reference ​

How the 6 assertions of cases/radio.json map to xUnit tests (tests/LhRadioTests.cs):

case idAssertionLocal test
tap-unchecked-emits-onchangeA tap on an unchecked radio fires onChangeTap_Unchecked_Emits_OnChange
tap-checked-keeps-checkedTapping a checked radio does not fireTap_Checked_Keeps_Checked
disabled-blocks-changeThe disabled state is not interactiveDisabled_Blocks_Change
checked-uses-primary-tokensThe checked state consumes the primary tokensChecked_Uses_Primary_Tokens
unchecked-uses-border-tokenThe unchecked state consumes the border tokenUnchecked_Uses_Border_Token
small-size-uses-small-tokenSmall consumes the small size tokenSmall_Size_Uses_Small_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)