Typography 提供通用的排版组件。包含 Text(文本)和 Title(标题)两个子组件。
Title — 标题
H1 标题
H2 标题
H3 标题
H4 标题
H5 标题
<Typography.Title appearance={{ level: 1 }}>H1 标题</Typography.Title>
<Typography.Title appearance={{ level: 2 }}>H2 标题</Typography.Title>
<Typography.Title appearance={{ level: 3 }}>H3 标题</Typography.Title>
Text — 颜色变体
PrimarySecondaryTertiarySuccessWarningErrorLink
<Typography.Text appearance={{ variant: 'primary' }}>Primary</Typography.Text>
<Typography.Text appearance={{ variant: 'success' }}>Success</Typography.Text>
Text — Size
XSSMMDLG
Text — 样式修饰
StrongItalicUnderlineStrikeDisabledMarkCode
<Typography.Text state={{ strong: true }}>Strong</Typography.Text>
<Typography.Text state={{ italic: true }}>Italic</Typography.Text>
<Typography.Text state={{ strike: true }}>Strike</Typography.Text>
<Typography.Text appearance={{ mark: true }}>Mark</Typography.Text>
<Typography.Text appearance={{ code: true }}>Code</Typography.Text>
Props 参考
Title Props
state — 运行时状态
| Prop | 类型 | 默认值 | 说明 |
|---|
state.strong | boolean | false | 加粗 |
state.italic | boolean | false | 斜体 |
state.underline | boolean | false | 下划线 |
appearance — 视觉外观
| Prop | 类型 | 默认值 | 说明 |
|---|
appearance.level | 1 | 2 | 3 | 4 | 5 | 1 | 标题级别(映射字号) |
appearance.variant | 'default' | 'secondary' | 'tertiary' | 'default' | 颜色变体 |
appearance.as | 'h1' | ... | 'h6' | 自动 | 自定义渲染标签 |
appearance.delete | boolean | false | 删除线 |
content — 渲染内容
| Prop | 类型 | 默认值 | 说明 |
|---|
content.children | React.ReactNode | — | 标题内容 |
content.ellipsis | boolean | false | 溢出省略 |
interaction — 事件回调
| Prop | 类型 | 默认值 | 说明 |
|---|
interaction.onClick | React.MouseEventHandler | — | 点击回调 |
Text Props
state — 运行时状态
| Prop | 类型 | 默认值 | 说明 |
|---|
state.strong | boolean | false | 加粗 |
state.italic | boolean | false | 斜体 |
state.underline | boolean | false | 下划线 |
state.strike | boolean | false | 删除线 |
state.disabled | boolean | false | 禁用状态 |
state.copyable | boolean | false | 可复制标记 |
appearance — 视觉外观
| Prop | 类型 | 默认值 | 说明 |
|---|
appearance.variant | 'primary' | 'secondary' | 'tertiary' | 'success' | 'warning' | 'error' | 'link' | 'primary' | 颜色变体 |
appearance.size | 'xs' | 'sm' | 'md' | 'lg' | 'md' | 字号 |
appearance.mark | boolean | false | 高亮标记样式 |
appearance.code | boolean | false | 代码样式 |
appearance.keyboard | boolean | false | 键盘按键样式 |
content — 渲染内容
| Prop | 类型 | 默认值 | 说明 |
|---|
content.children | React.ReactNode | — | 文本内容 |
content.ellipsis | boolean | false | 溢出省略 |
interaction — 事件回调
| Prop | 类型 | 默认值 | 说明 |
|---|
interaction.onClick | React.MouseEventHandler | — | 点击回调 |
interaction.onExpand | () => void | — | 省略展开回调 |
override / a11y — 所有组件必有
override: className、style
a11y: ariaLabel、role(Text)、ariaLabel(Title)