Skip to content

Button ボタン ​

基本的な操作ボタンです。即時操作をトリガーし、タイプ、サイズ、読み込み、無効化、アイコン、中華風の紋様背景をサポートします。

契約元:lh-ui-core/specs/button.json · ゴールデンケース:lh-ui-core/cases/button.json(8 件、xUnit テストに翻訳済み)

タイプ ​

6 種類のタイプが背景色とテキスト色を決定します。

9:41Button タイプ

HTML シミュレーションプレビュー(Windows / WinUI 3 の見た目)。実機レンダリングではありません

csharp
var button = new LhButton
{
    Type = LhButtonType.Primary,
    Text = "プライマリボタン",
};
button.Click += OnButtonClick;

サイズ ​

3 段階のサイズが button.height / paddingHorizontal / fontSize / iconSize トークンに対応します。

9:41Button サイズ

HTML シミュレーションプレビュー(Windows / WinUI 3 の見た目)。実機レンダリングではありません

状態 ​

無効と読み込み中はどちらも Click を発火しません。両方指定された場合は無効が優先されます(ゴールデンケース disabled-precedes-loading)。

9:41Button 状態

HTML シミュレーションプレビュー(Windows / WinUI 3 の見た目)。実機レンダリングではありません

アイコンと紋様背景 ​

アイコン名はローカルのアイコン体系で解決されます(LhButtonTokens.IconFor、現在は search / refresh / check / close をサポート、未登録名は描画されません)。紋様背景は color.decoration トークンを消費し、45° の斜線として重なり描画されます。

9:41アイコンと紋様

HTML シミュレーションプレビュー(Windows / WinUI 3 の見た目)。実機レンダリングではありません

ライト / ダークテーマ ​

サイト右上のテーマを切り替えると、シミュレーターの携帯フレーム内のボタン色が変わります。実機では LhTheme.Apply(true) で切り替えます。

9:41ダークボタン

HTML シミュレーションプレビュー(Windows / WinUI 3 の見た目)。実機レンダリングではありません。ライト / ダークの値はすべて core のトークンスナップショットから取得

API ​

プロパティ ​

プロパティ説明型デフォルト値
Clickクリックイベント。Disabled または Loading が true の場合は発火しないevent Action—
Typeボタンタイプ。背景色とテキスト色を決定LhButtonTypeDefault
Sizeボタンサイズ。サイズトークンに対応LhButtonSizeMedium
Disabled無効かどうかboolfalse
Loading読み込み中かどうか(インジケーターを表示し、Click を発火しない)boolfalse
Iconアイコン名(ローカルのアイコン体系で解決)string?null
BgPattern中華風の紋様背景を描画するかどうかboolfalse
Textボタンのテキスト内容(spec の default スロット)string""

LhButtonType ​

値背景色テキスト色
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 ​

値heightpaddingHorizontalfontSizeiconSize
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)

無効状態の上書き:背景 color.disabled.bg、テキスト color.disabled.text、ボーダー color.disabled.border。

トークン对照 ​

ボタンが消費するトークン(specs/button.json の tokenRefs と一対一で対応):

トークン用途
button.height.{small,medium,large}3 段階の高さ
button.paddingHorizontal.{small,medium,large}3 段階の横向きパディング
button.fontSize.{small,medium,large}3 段階のフォントサイズ
button.iconSize.{small,medium,large}3 段階のアイコンサイズ
button.borderRadius / button.borderWidth角丸(radius.base に追従)とボーダー幅
button.fontWeightフォントの太さ(typography.fontWeight.primary に追従、エンド側で FontWeights にマッピング)
color.primary.default / color.onPrimaryプライマリタイプの背景 / テキスト
color.{success,warning,danger,info}.defaultセマンティックタイプの背景色
color.background.default / color.text.primary / color.border.baseデフォルトタイプの背景 / テキスト / ボーダー
color.disabled.{bg,text,border}無効状態の三色
color.decoration紋様の色
spacing.xsアイコンとテキストの間隔
typography.fontFamily中華風セリフフォントスタック

ゴールデンケース对照 ​

cases/button.json の 8 件のアサーションと xUnit テストの対応関係(tests/LhButtonTests.cs):

case idアサーションローカルテスト
click-emits-ononclickゲートが通す(インタラクティブ)Enabled_Button_Is_Interactive
disabled-blocks-click無効状態はインタラクティブでないDisabled_Is_Not_Interactive
loading-blocks-click読み込み状態はインタラクティブでないLoading_Is_Not_Interactive
disabled-precedes-loading無効が優先 + 無効スタイルDisabled_Precedes_Loading
default-type-renders-textデフォルトタイプのニュートラルな背景 / テキストDefault_Type_Uses_Neutral_Tokens
primary-type-uses-primary-tokensプライマリタイプがプライマリトークンを消費Primary_Type_Uses_Primary_Tokens
small-size-uses-small-tokens小サイズが small サイズトークンを消費Small_Size_Uses_Small_Tokens
bgpattern-uses-decoration-token紋様背景が装飾色を消費BgPattern_Uses_Decoration_Token

さらにダーク専用のテストがあります:Dark_Colors_Come_From_Dark_Tokens / Dimensions_Are_Identical_In_Dark_Mode。 実行:cd lh-ui-windows && dotnet test。

lh-ui ネイティブ血脈 · Windows 端(C# + WinUI 3)