Text 텍스트
텍스트 표시 원시 요소: 전역 타이포그래피 토큰을 소비하며, 폰트 크기 등급, 글꼴 두께, 색조, 정렬을 지원합니다.
계약 원본:
lh-ui-core/specs/text.json· 골든 케이스:lh-ui-core/cases/text.json(5건, hypium 테스트로 번역됨)
폰트 크기 등급
level이 typography.fontSize.<level> 토큰에 매핑되며 기본값은 base입니다.
최대 extraLarge
대형 large
중형 medium
기본 base(기본값)
소형 small
최소 extraSmall
HTML 시뮬레이션 미리 보기(HarmonyOS / ArkUI 외관), 실기기 렌더링 아님
LhText({ content: '제목 텍스트', level: LhTextLevel.Large })글꼴 두께
weight가 typography.fontWeight.<weight> 토큰에 매핑됩니다(primary 400 / bold 600).
일반 primary(기본값)
굵게 bold
HTML 시뮬레이션 미리 보기(HarmonyOS / ArkUI 외관), 실기기 렌더링 아님
색조
tone이 color.text.<tone> 토큰에 매핑됩니다; selected는 color.selected를 사용합니다.
주요 primary(기본값)
일반 regular
보조 secondary
플레이스홀더 placeholder
비활성화 disabled
선택됨 selected
HTML 시뮬레이션 미리 보기(HarmonyOS / ArkUI 외관), 실기기 렌더링 아님
정렬과 줄 높이
align은 글자가 줄 상자 너비 안에서 수평으로 정렬되는 방식을 결정합니다(디자인 토큰이 아니며 프레임워크 열거형에 매핑); 줄 높이는 항상 typography.lineHeight.primary이며 layout 높이 = 폰트 크기 × 줄 높이.
왼쪽 정렬 start(기본값)
가운데 정렬 center
오른쪽 정렬 end
HTML 시뮬레이션 미리 보기(HarmonyOS / ArkUI 외관), 실기기 렌더링 아님
LhText({ content: '오른쪽 정렬', align: LhTextAlign.End })라이트/다크 테마
사이트 우측 상단에서 테마를 전환하면 시뮬레이터 폰 프레임 안의 글자 색이 바뀝니다; 실기기에서는 LhTheme.apply(true)로 전환합니다.
큰 제목
본문 주 색상
보조 설명
HTML 시뮬레이션 미리 보기(HarmonyOS / ArkUI 외관), 실기기 렌더링 아님; 라이트/다크값은 모두 core 토큰 스냅샷에서 가져옴
API
Props
| 프로퍼티 | 설명 | 타입 | 기본값 |
|---|---|---|---|
content | 텍스트 내용(spec의 default 슬롯) | string | '' |
level | 폰트 크기 등급, typography.fontSize.<level>에 매핑 | LhTextLevel | Base |
weight | 글꼴 두께, typography.fontWeight.<weight>에 매핑 | LhTextWeight | Primary |
tone | 글자 색조, color.text.<tone> 또는 color.selected에 매핑 | LhTextTone | Primary |
align | 수평 정렬 방식(줄 상자 너비 안에서 적용) | LhTextAlign | Start |
LhTextLevel
| 값 | fontSize |
|---|---|
ExtraLarge | typography.fontSize.extraLarge (20) |
Large | typography.fontSize.large (18) |
Medium | typography.fontSize.medium (16) |
Base | typography.fontSize.base (14) |
Small | typography.fontSize.small (13) |
ExtraSmall | typography.fontSize.extraSmall (12) |
LhTextWeight
| 값 | fontWeight |
|---|---|
Primary | typography.fontWeight.primary (400) |
Bold | typography.fontWeight.bold (600) |
LhTextTone
| 값 | 글자 색 |
|---|---|
Primary | color.text.primary |
Regular | color.text.regular |
Secondary | color.text.secondary |
Placeholder | color.text.placeholder |
Disabled | color.text.disabled |
Selected | color.selected |
LhTextAlign
| 값 | 엔드 측 매핑 |
|---|---|
Start | TextAlign.Start |
Center | TextAlign.Center |
End | TextAlign.End |
토큰 매핑
텍스트가 소비하는 토큰(specs/text.json의 tokenRefs와 한 줄씩 정렬, 모두 전역 토큰입니다 — text에는 컴포넌트 수준 토큰이 없습니다):
| 토큰 | 용도 |
|---|---|
typography.fontSize.{extraLarge,large,medium,base,small,extraSmall} | 6단계 폰트 크기 |
typography.fontWeight.{primary,bold} | 2단계 글꼴 두께 |
typography.lineHeight.primary | 줄 높이(layout 높이 = 폰트 크기 × 줄 높이) |
color.text.{primary,regular,secondary,placeholder,disabled} | 5단계 글자 색조 |
color.selected | 선택 상태 글자 색 |
골든 케이스 매핑
cases/text.json의 5건 어서션과 hypium 테스트의 대응 관계(entry/src/test/Text.test.ets):
| case id | 어서션 | 로컬 테스트 |
|---|---|---|
default-level-uses-base-tokens | 기본 등급이 base 타이포그래피 토큰 세트 소비 | default_level_uses_base_tokens |
large-level-uses-large-token | large 폰트 크기 토큰 적용, base 오용 없음 | large_level_uses_large_token |
bold-weight-uses-bold-token | bold 글꼴 두께 토큰 적용, primary 오용 없음 | bold_weight_uses_bold_token |
secondary-tone-uses-text-secondary | secondary 글자 색 토큰 적용 | secondary_tone_uses_text_secondary |
render-emits-single-text-command | 명령 스트림에 TEXT 명령이 하나만 존재 | resolve_produces_single_complete_text_style |
이 밖에 다크 전용 테스트가 있습니다: dark_colors_come_from_dark_tokens / dimensions_are_identical_in_dark_mode. 실행: DevEco Studio에서 entry/src/test 우클릭 → Run Tests.

