Text テキスト
テキスト表示プリミティブ:グローバル組版トークンを消費し、サイズレベル・字重・色調・整列をサポート。
契約元:
lh-ui-core/specs/text.json· 黄金ケース:cases/text.json(5 件:トークン映射は JVM 単体テスト、レンダリングと単ノード検証は androidTest)
サイズレベル
level は typography.fontSize.<level> トークンにマッピング(デフォルト base)。
extraLarge
large
medium
base
small
extraSmall
HTML シミュレータプレビュー(Android / Compose の見た目)、実機レンダリングではありません
LhText(content = "Title text", level = LhTextLevel.large)字重
weight は typography.fontWeight.<weight> トークンにマッピング(primary 400 / bold 600)。
primary
bold
HTML シミュレータプレビュー(Android / Compose の見た目)、実機レンダリングではありません
色調
tone は color.text.<tone> トークンにマッピング。selected は color.selected を使用。
primary
regular
secondary
placeholder
disabled
selected
HTML シミュレータプレビュー(Android / Compose の見た目)、実機レンダリングではありません
整列と行高
lhAlign は行ボックス内で整列。行高は常に typography.lineHeight.primary(サイズ × 1.8)。
center
end
HTML シミュレータプレビュー(Android / Compose の見た目)、実機レンダリングではありません
LhText(content = "Centered", lhAlign = LhTextAlign.center)API
Props
| Prop | Description | Type | Default |
|---|---|---|---|
content | text content (string form of the spec default slot) | String | "" |
modifier | modifier | Modifier | Modifier |
level | font-size level | LhTextLevel | Base |
weight | font weight | LhTextWeight | Primary |
tone | text tone | LhTextTone | Primary |
lhAlign | horizontal alignment | LhTextAlign | Start |
LhTextLevel
| Value | fontSize token |
|---|---|
ExtraLarge | typography.fontSize.extraLarge (20sp) |
Large | typography.fontSize.large (18sp) |
Medium | typography.fontSize.medium (16sp) |
Base | typography.fontSize.base (14sp, default) |
Small | typography.fontSize.small (13sp) |
ExtraSmall | typography.fontSize.extraSmall (12sp) |
LhTextTone
| Value | text color token |
|---|---|
Primary | color.text.primary |
Regular | color.text.regular |
Secondary | color.text.secondary |
Placeholder | color.text.placeholder |
Disabled | color.text.disabled |
Selected | color.selected |
トークン对照
| Token | Usage |
|---|---|
typography.fontSize.<level> | six size levels |
typography.fontWeight.{primary,bold} | two weights |
typography.lineHeight.primary | line height (font size × 1.8) |
color.text.<tone> / color.selected | text tones |
黄金ケース对照
| case id | アサーション | ローカルテスト |
|---|---|---|
default-level-uses-base-tokens | default level consumes the base typography tokens | LhTextDefaultsTest.default_level_uses_base_tokens / LhTextTest.default_level_renders_content |
large-level-uses-large-token | large level consumes the large size token | LhTextDefaultsTest.large_level_uses_large_token / LhTextTest.large_level_renders_content |
bold-weight-uses-bold-token | bold consumes the bold weight token | LhTextDefaultsTest.bold_weight_uses_bold_token |
secondary-tone-uses-text-secondary | secondary tone takes the secondary text color token | LhTextDefaultsTest.secondary_tone_uses_text_secondary |
render-emits-single-text-command | render emits a single TEXT command | LhTextTest.renders_single_text_node(単ノード検証) |
./gradlew :components:text:test # JVM 部分(トークン映射)
./gradlew :components:text:connectedAndroidTest # 計測部分(デバイス必要)
