焦点降噪目录列表
极简个人站出镜率最高的目录组件:平时安静克制,鼠标悬停任意一行时,其余兄弟行自动柔和降噪退暗,配合点状引导线与等宽年份对齐。
目录与索引5 项可调参数React + Tailwind
演示与调参
核心不在写复杂的 JS,而在于把容器级 hover 状态与单行 hover 状态解耦:父容器悬停时统一把所有子行降到 dimOpacity,再把当前悬停行单独拉回 1.0 不透明度。
IndexRelational design teardown & recipe library
预设
布局结构
刻度垂直间距12px
中段连接线
动效反馈
非焦点透明度0.36
展开过渡时长160ms
表面与质感
focus-dimming-index
复刻提示词
请用 React + Tailwind CSS 实现一个极简个人站「焦点降噪目录列表(Focus-Dimming Index)」组件(风格参考 paco.me 与 benji.org)。
精确排版与交互参数要求:
- 容器最大宽度 600px,纯白背景(#FFFFFF),主文字颜色 #111113,次要年份信息使用等宽字体(tabular-nums)与浅灰 #86868E。
- 单行结构:左侧为项目标题(附一枚 #F3F3F5 浅灰微胶囊展示分类),中间用一条自适应宽度的 1px 虚线(dotted rgba(0,0,0,0.14)) 连接,右侧对齐等宽年份。
- 行上下内边距严格设为 12px,悬停时禁止产生任何文字位移或抖动。
- 核心焦点降噪动效:当鼠标进入整个列表区域时,非当前悬停的所有兄弟行在 160ms(ease-out)内平滑降低不透明度至 0.36,仅当前悬停行保持 1.0 清晰高亮;移出列表恢复全部 1.0。
- 无障碍与降级:键盘 Tab 聚焦(focus-visible)具备同等高亮效果,并兼容 prefers-reduced-motion。代码
FocusDimmingIndex.tsxReact · Tailwind
import React, { useState } from "react";
const ITEMS = [
{ title: "Linear Design System", tag: "System", year: "2026", href: "#linear" },
{ title: "MemoryNook", tag: "Product", year: "2026", href: "#nook" },
{ title: "Fluid Typography Notes", tag: "Essay", year: "2025", href: "#essay" },
{ title: "Command Palette Primitives", tag: "Craft", year: "2025", href: "#cmdk" },
];
export function FocusDimmingIndex() {
const [activeIndex, setActiveIndex] = useState<number | null>(null);
return (
<nav aria-label="Selected work" className="mx-auto w-full max-w-[600px]">
<ul
onMouseLeave={() => setActiveIndex(null)}
className="divide-y divide-transparent"
>
{ITEMS.map((item, idx) => {
const isDimmed = activeIndex !== null && activeIndex !== idx;
return (
<li key={item.title}>
<a
href={item.href}
onMouseEnter={() => setActiveIndex(idx)}
onFocus={() => setActiveIndex(idx)}
onBlur={() => setActiveIndex(null)}
style={{
paddingTop: "12px",
paddingBottom: "12px",
opacity: isDimmed ? 0.36 : 1,
transition: "opacity 160ms ease-out",
}}
className="flex items-center gap-3 text-[15px] text-[#111113] focus-visible:outline-none"
>
<span className="font-medium tracking-[-0.01em]">{item.title}</span>
<span className="rounded-md bg-[#F3F3F5] px-1.5 py-0.5 text-[11px] text-[#52525B]">{item.tag}</span>
<span className="flex-1 border-b border-dotted border-black/15" />
<span className="font-mono text-[13px] tabular-nums text-[#86868E]">
{item.year}
</span>
</a>
</li>
);
})}
</ul>
</nav>
);
}参数参考
| 属性 | 默认值 | 当前值 | 说明 |
|---|---|---|---|
rowGapPx 刻度垂直间距 | 12 | 12 | 控制每条目录或章节刻度之间的垂直呼吸留白。 |
leaderStyle 中段连接线 | dotted | dotted | 连接左侧项目标题与右侧年份的视觉引导线样式。 |
dimOpacity 非焦点透明度 | 0.36 | 0.36 | 鼠标悬停某一行时,其余兄弟行自动退暗的目标透明度。 |
durationMs 展开过渡时长 | 160 | 160 | 刻度伸展与章节文字滑入的过渡耗时。 |
showRoleBadge 显示分类徽标 | true | true | 是否在项目标题旁附带一枚极轻的浅灰分类胶囊。 |