标题
对齐目标:@astryxdesign/core v0.7.1 · Heading
Heading Level 1
Heading Level 2
Heading Level 3
Heading Level 4
Heading Level 5
Heading Level 6
使用方法 #
Heading 用于渲染页面和区块的标题:level 决定语义层级(h1–h6),type 可以在不改变语义的前提下调整视觉样式,两者搭配能同时照顾文档结构与视觉设计。从独立入口导入即可,结构样式会随组件自动加载:
Vue
<script setup lang="ts">
import { Heading } from '@astryx-vue/core/Heading'
</script>
<template>
<Heading :level="1">
页面标题
</Heading>
<Heading :level="2" type="display-2">
数据概览
</Heading>
</template>最佳实践 #
| 指引 | 实践 |
|---|---|
| 推荐 | 按文档大纲选择 level,保持层级连贯、不跳级,屏幕阅读器和搜索引擎才能正确理解页面结构。 |
| 推荐 | 需要营销页或大号展示效果时,用 type="display-*" 覆盖视觉样式,同时保留语义正确的 level。 |
| 推荐 | 层级较低的次要标题可以使用 color="secondary",让它在视觉上退后一步,主要标题更突出。 |
| 避免 | 为了视觉大小而选用与页面结构不符的 level:视觉样式交给 type 控制,语义层级仍由 level 决定。 |
| 避免 | 在标题中塞入长段落:标题应简短概括内容,详细说明放到正文里。 |
示例 #
标题 — 卡片网格
Card Title
This is a card description that might be quite long and needs to be truncated after two lines to keep the card compact and uniform. Updated 1 hour ago响应式卡片网格。标题和说明被截断,让每张卡片高度一致。
标题 — 页面层级
Dashboard Overview
Last updated 5 minutes agoRecent Activity
Here's what's been happening in your workspace.Today
• Project Alpha updated• 3 new comments
• Task completed
真实页面布局,用 h1 到 h3 和配套说明展示标题层级。
标题 — 截断
Very Long Heading That Will Be Truncated To One Line With Ellipsis
Very Long Heading That Will Be Truncated To Two Lines To Keep Card Layout Compact
在有限宽度里把标题截成一行或两行,并以省略号结尾。截断后悬停可读全文。
标题 — 大纲与对齐
Quarterly review
Draft agenda
The visual size stays on the page. The outline level is what assistive technology reads.
视觉层级和读屏层级可以分开。删除线和对齐跟着标题走。