table · minimal · 灵感来源:GOV.UK table / USWDS usa-table
表头不用大写小字,一条分隔线就够分层
| 组件 | 类型 | 材质数 | 浏览量 | 更新 |
|---|---|---|---|---|
| 玻璃按钮 | 按钮 | 3 | 1 284 | 2026-10-24 |
| 玻璃输入框 | 输入 | 3 | 963 | 2026-10-30 |
| 玻璃抽屉 | 抽屉 | 3 | 12 407 | 2026-10-31 |
| 极简通知 | 通知 | 3 | 77 | 2026-10-19 |
| 拟态骨架屏 | 骨架 | 3 | 5 | 2026-10-12 |
Data Table · 极简数据表 · 表格 / Minimal
做一个 Data Table(极简数据表):
- 同一份 props(caption / columns / rows / className)
- 平底 + 发丝线,零模糊零 inset;表头用正文小号,不用大写小字
- 悬停换底色不换阴影——极简没有"按下去"这回事
- 对齐、滚动与只读边界同玻璃数据表
用这些 CSS 变量:--color-bg --color-divider --color-surface --color-text --color-text-muted
灵感参考:GOV.UK table / USWDS usa-table--color-bg --color-divider --color-surface --color-text --color-text-muted
悬停 / 焦点
(尚未接进整页场景)
/r/table--minimal.json
免外壳的 markdown 版:/llms/components/table--minimal.md--color-bg),不换阴影:极简没有"按下去"这回事framed=false:只留滚动容器,材质底不重复画import { type ReactNode } from 'react';
export interface TableColumn {
key: string;
header: string;
/** end = 数字列:表头与数值一起右对齐(GOV / Polaris 同一条) */
align?: 'start' | 'end';
/** 列宽只写 Tailwind 宽度类,不写 px 字面量 */
width?: string;
}
export interface TableRow {
id: string;
cells: Record<string, ReactNode>;
}
interface Props {
caption: string;
columns: TableColumn[];
rows: TableRow[];
/** false = 只留滚动容器,材质底交给外层面板(嵌在卡片里时不再套一层卡) */
framed?: boolean;
className?: string;
}
/** 极简数据表:材质签名 = 平底 + 发丝线,表头不用大写小字,靠留白与一条分隔线分层 */
export function MinimalTable({ caption, columns, rows, framed = true, className = '' }: Props) {
return (
<div
role="region"
aria-label={caption}
tabIndex={0}
className={`overflow-x-auto outline-offset-2 ${framed ? 'rounded-md bg-[var(--color-surface)]' : ''} ${className}`}
>
<table className="w-full min-w-[34rem] border-collapse text-sm">
<caption className="sr-only">{caption}</caption>
<thead>
<tr className="border-b border-[var(--color-divider)]">
{columns.map((c) => (
<th
key={c.key}
scope="col"
className={`
px-4 py-3 text-xs font-medium text-[var(--color-text-muted)] whitespace-nowrap
${c.align === 'end' ? 'text-right' : 'text-left'}
${c.width ?? ''}
`}
>
{c.header}
</th>
))}
</tr>
</thead>
<tbody>
{rows.map((row) => (
<tr
key={row.id}
className="border-b border-[var(--color-divider)] last:border-b-0 transition-colors hover:bg-[var(--color-bg)]"
>
{columns.map((c, i) =>
i === 0 ? (
<th
key={c.key}
scope="row"
className="px-4 py-3 text-left font-medium text-[var(--color-text)] break-words"
>
{row.cells[c.key]}
</th>
) : (
<td
key={c.key}
className={`
px-4 py-3 text-[var(--color-text-muted)] break-words
${c.align === 'end' ? 'text-right tabular-nums whitespace-nowrap' : ''}
`}
>
{row.cells[c.key]}
</td>
),
)}
</tr>
))}
</tbody>
</table>
</div>
);
}
src/components/table/minimal/