组件 · COMPONENT
面包屑 Breadcrumb
层级轨迹:灰字可点、悬停变墨,末项是墨色加粗的当前页,斜杠分隔。全站课程页把它钉在顶栏。
import { Breadcrumb } from './components/v4/Breadcrumb.jsx'
export function Basic() {
return (
<Breadcrumb items={[
{ label: '综合首页', onClick: () => {} },
{ label: 'Obsidian 知识管理', onClick: () => {} },
{ label: '学习地图' },
]} />
)
}<nav
aria-label="面包屑"
style="
display: flex;
align-items: center;
gap: 8px;
min-width: 0;
font-size: 12px;
color: #8b8b85;
flex-wrap: wrap;
"
>
<button
type="button"
class="zzm-inklink"
style="
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
line-height: 20px;
border: 0;
background: transparent;
padding: 4px 0;
cursor: pointer;
font-family: inherit;
font-size: inherit;
text-align: left;
"
>
综合首页
</button>
<span aria-hidden="true" style="flex: none; color: #c6c6c0">/</span>
<button
type="button"
class="zzm-inklink"
style="
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
line-height: 20px;
border: 0;
background: transparent;
padding: 4px 0;
cursor: pointer;
font-family: inherit;
font-size: inherit;
text-align: left;
"
>
Obsidian 知识管理
</button>
<span aria-hidden="true" style="flex: none; color: #c6c6c0">/</span>
<span
aria-current="page"
style="
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
line-height: 20px;
color: #161616;
font-weight: 600;
"
>
学习地图
</span>
</nav>/* base.css */
.zzm-v4 .zzm-inklink { color: inherit; transition: color .16s ease; }
.zzm-v4 .zzm-inklink:hover { color: #161616; }
.zzm-v4 .zzm-inklink:focus-visible { outline: none; border-radius: 4px; box-shadow: 0 0 0 3px rgba(166, 64, 47, .2); }import { Breadcrumb } from './components/v4/Breadcrumb.jsx'
export function Narrow() {
return (
<div style={{ width: 240 }}>
<Breadcrumb
style={{ flexWrap: 'nowrap', overflow: 'hidden' }}
items={[
{ label: '综合首页', onClick: () => {} },
{ label: 'Obsidian 知识管理', onClick: () => {} },
{ label: '双链与反向链接:让想法第一次连起来' },
]}
/>
</div>
)
}<div style="width: 240px">
<nav
aria-label="面包屑"
style="
display: flex;
align-items: center;
gap: 8px;
min-width: 0;
font-size: 12px;
color: #8b8b85;
flex-wrap: nowrap;
overflow: hidden;
"
>
<button
type="button"
class="zzm-inklink"
style="
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
line-height: 20px;
border: 0;
background: transparent;
padding: 4px 0;
cursor: pointer;
font-family: inherit;
font-size: inherit;
text-align: left;
"
>
综合首页
</button>
<span aria-hidden="true" style="flex: none; color: #c6c6c0">/</span>
<button
type="button"
class="zzm-inklink"
style="
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
line-height: 20px;
border: 0;
background: transparent;
padding: 4px 0;
cursor: pointer;
font-family: inherit;
font-size: inherit;
text-align: left;
"
>
Obsidian 知识管理
</button>
<span aria-hidden="true" style="flex: none; color: #c6c6c0">/</span>
<span
aria-current="page"
style="
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
line-height: 20px;
color: #161616;
font-weight: 600;
"
>
双链与反向链接:让想法第一次连起来
</span>
</nav>
</div>/* base.css */
.zzm-v4 .zzm-inklink { color: inherit; transition: color .16s ease; }
.zzm-v4 .zzm-inklink:hover { color: #161616; }
.zzm-v4 .zzm-inklink:focus-visible { outline: none; border-radius: 4px; box-shadow: 0 0 0 3px rgba(166, 64, 47, .2); }属性
| 属性 | 取值 | 默认 | 说明 |
|---|---|---|---|
| items | [{ label, onClick? }] | [] | 有 onClick 渲染为可点按钮;没有的是当前页(aria-current);null 项自动过滤 |
| style | object | — | 并入 nav 容器;窄处传 flexWrap / overflow |
规格
12px · 项色 #8B8B85(由容器继承)· 分隔符 #C6C6C0 · 当前项 #161616 / 600 · 间距 8 · 行高 20。可点项用 .zzm-inklink:基色 inherit,悬停变墨,键盘焦点朱色光晕。
铁律
✓ 要颜色交给容器继承
✗ 不要在项上写内联
color——它会压死 :hover✓ 要轨迹由页面自己组,组件只管长相