Descriptions#
数据展示
@rockshin/tao-ui以结构化详情展示带标签的字段。
组件采用 tao-ui 原生实现,公共 API 对齐 Ant Design 6.7.0。外观、主题 token 与 Semantic DOM 定制遵循 tao-ui,主题通过 TaoProvider 配置。
items、响应式列数与跨列遵循 6.7.0;默认在手机一列、桌面三列之间适配,使用 tao-ui 断点。
#何时使用
用于只读的账户、订单或配置详情。
#代码演示
#基础详情
Account
NameAda Lovelace | PlanTeam | RegionLondon |
StatusActive | ||
TSX
import { Descriptions } from "@rockshin/tao-ui";
const items = [
{ key: "name", label: "Name", children: "Ada Lovelace" },
{ key: "plan", label: "Plan", children: "Team" },
{ key: "region", label: "Region", children: "London" },
{ key: "status", label: "Status", children: "Active" },
];
export default function Example() {
return <Descriptions title="Account" items={items} />;
}#边框与紧凑尺寸
Account
| Name | Ada Lovelace | Plan | Team |
|---|---|---|---|
| Region | London | Status | Active |
TSX
import { Descriptions } from "@rockshin/tao-ui";
const items = [
{ key: "name", label: "Name", children: "Ada Lovelace" },
{ key: "plan", label: "Plan", children: "Team" },
{ key: "region", label: "Region", children: "London" },
{ key: "status", label: "Status", children: "Active" },
];
export default function Example() {
return (
<Descriptions
title="Account"
items={items}
bordered
size="small"
column={2}
/>
);
}#垂直字段
Name | Plan |
|---|---|
Ada Lovelace | Team |
Region | Status |
London | Active |
TSX
import { Descriptions } from "@rockshin/tao-ui";
const items = [
{ key: "name", label: "Name", children: "Ada Lovelace" },
{ key: "plan", label: "Plan", children: "Team" },
{ key: "region", label: "Region", children: "London" },
{ key: "status", label: "Status", children: "Active" },
];
export default function Example() {
return (
<Descriptions layout="vertical" items={items} column={2} colon={false} />
);
}#跨列与填满余位
TSX
import { Descriptions } from "@rockshin/tao-ui";
export default function Example() {
return (
<Descriptions
bordered
column={3}
items={[
{ label: "Name", children: "Ada", span: 2 },
{ label: "Status", children: "Active" },
{
label: "Notes",
children: "Available to all workspace members",
span: "filled",
},
{ label: "Owner", children: "Engineering" },
{ label: "Region", children: "Global", span: "filled" },
]}
/>
);
}#响应式列数
TSX
import { Descriptions } from "@rockshin/tao-ui";
const items = [
{ key: "name", label: "Name", children: "Ada Lovelace" },
{ key: "plan", label: "Plan", children: "Team" },
{ key: "region", label: "Region", children: "London" },
{ key: "status", label: "Status", children: "Active" },
];
export default function Example() {
return (
<Descriptions
title="Responsive account"
bordered
items={items}
column={{ xs: 1, sm: 2, lg: 3 }}
/>
);
}#操作与语义样式
Billing details
NameAda Lovelace | PlanTeam | |
TSX
import { useState } from "react";
import { Button, Descriptions } from "@rockshin/tao-ui";
const items = [
{ key: "name", label: "Name", children: "Ada Lovelace" },
{ key: "plan", label: "Plan", children: "Team" },
{ key: "region", label: "Region", children: "London" },
{ key: "status", label: "Status", children: "Active" },
];
export default function Example() {
const [editing, setEditing] = useState(false);
return (
<Descriptions
title="Billing details"
extra={
<Button size="small" onClick={() => setEditing(!editing)}>
{editing ? "Show less" : "Show all"}
</Button>
}
items={editing ? items : items.slice(0, 2)}
styles={{
label: { color: "var(--tao-color-text-secondary)" },
content: { fontWeight: 600 },
}}
/>
);
}#API
#Descriptions
| 属性 | 说明 | 类型 | 默认值 |
|---|