Descriptions描述列表

成组展示多个只读字段。

何时使用

常见于详情页的信息展示。

代码演示

Descriptions描述列表 - 图1

基本

简单的展示。

  1. import { Descriptions } from 'antd';
  2. ReactDOM.render(
  3. <Descriptions title="User Info">
  4. <Descriptions.Item label="UserName">Zhou Maomao</Descriptions.Item>
  5. <Descriptions.Item label="Telephone">1810000000</Descriptions.Item>
  6. <Descriptions.Item label="Live">Hangzhou, Zhejiang</Descriptions.Item>
  7. <Descriptions.Item label="Remark">empty</Descriptions.Item>
  8. <Descriptions.Item label="Address">
  9. No. 18, Wantang Road, Xihu District, Hangzhou, Zhejiang, China
  10. </Descriptions.Item>
  11. </Descriptions>,
  12. mountNode,
  13. );

Descriptions描述列表 - 图2

带边框的

带边框和背景颜色列表。

  1. import { Descriptions, Badge } from 'antd';
  2. ReactDOM.render(
  3. <Descriptions title="User Info" bordered>
  4. <Descriptions.Item label="Product">Cloud Database</Descriptions.Item>
  5. <Descriptions.Item label="Billing Mode">Prepaid</Descriptions.Item>
  6. <Descriptions.Item label="Automatic Renewal">YES</Descriptions.Item>
  7. <Descriptions.Item label="Order time">2018-04-24 18:00:00</Descriptions.Item>
  8. <Descriptions.Item label="Usage Time" span={2}>
  9. 2019-04-24 18:00:00
  10. </Descriptions.Item>
  11. <Descriptions.Item label="Status" span={3}>
  12. <Badge status="processing" text="Running" />
  13. </Descriptions.Item>
  14. <Descriptions.Item label="Negotiated Amount">$80.00</Descriptions.Item>
  15. <Descriptions.Item label="Discount">$20.00</Descriptions.Item>
  16. <Descriptions.Item label="Official Receipts">$60.00</Descriptions.Item>
  17. <Descriptions.Item label="Config Info">
  18. Data disk type: MongoDB
  19. <br />
  20. Database version: 3.4
  21. <br />
  22. Package: dds.mongo.mid
  23. <br />
  24. Storage space: 10 GB
  25. <br />
  26. Replication factor: 3
  27. <br />
  28. Region: East China 1<br />
  29. </Descriptions.Item>
  30. </Descriptions>,
  31. mountNode,
  32. );

Descriptions描述列表 - 图3

自定义尺寸

自定义尺寸,适应在各种容器中展示。

  1. import { Descriptions, Radio, Button } from 'antd';
  2. class Demo extends React.Component {
  3. state = {
  4. size: 'default',
  5. };
  6. onChange = e => {
  7. console.log('size checked', e.target.value);
  8. this.setState({
  9. size: e.target.value,
  10. });
  11. };
  12. render() {
  13. return (
  14. <div>
  15. <Radio.Group onChange={this.onChange} value={this.state.size}>
  16. <Radio value="default">default</Radio>
  17. <Radio value="middle">middle</Radio>
  18. <Radio value="small">small</Radio>
  19. </Radio.Group>
  20. <br />
  21. <br />
  22. <Descriptions
  23. bordered
  24. title="Custom Size"
  25. size={this.state.size}
  26. extra={<Button type="primary">Edit</Button>}
  27. >
  28. <Descriptions.Item label="Product">Cloud Database</Descriptions.Item>
  29. <Descriptions.Item label="Billing">Prepaid</Descriptions.Item>
  30. <Descriptions.Item label="time">18:00:00</Descriptions.Item>
  31. <Descriptions.Item label="Amount">$80.00</Descriptions.Item>
  32. <Descriptions.Item label="Discount">$20.00</Descriptions.Item>
  33. <Descriptions.Item label="Official">$60.00</Descriptions.Item>
  34. <Descriptions.Item label="Config Info">
  35. Data disk type: MongoDB
  36. <br />
  37. Database version: 3.4
  38. <br />
  39. Package: dds.mongo.mid
  40. <br />
  41. Storage space: 10 GB
  42. <br />
  43. Replication factor: 3
  44. <br />
  45. Region: East China 1<br />
  46. </Descriptions.Item>
  47. </Descriptions>
  48. <br />
  49. <br />
  50. <Descriptions
  51. title="Custom Size"
  52. size={this.state.size}
  53. extra={<Button type="primary">Edit</Button>}
  54. >
  55. <Descriptions.Item label="Product">Cloud Database</Descriptions.Item>
  56. <Descriptions.Item label="Billing">Prepaid</Descriptions.Item>
  57. <Descriptions.Item label="time">18:00:00</Descriptions.Item>
  58. <Descriptions.Item label="Amount">$80.00</Descriptions.Item>
  59. <Descriptions.Item label="Discount">$20.00</Descriptions.Item>
  60. <Descriptions.Item label="Official">$60.00</Descriptions.Item>
  61. </Descriptions>
  62. </div>
  63. );
  64. }
  65. }
  66. ReactDOM.render(<Demo />, mountNode);

Descriptions描述列表 - 图4

响应式

通过响应式的配置可以实现在小屏幕设备上的完美呈现。

  1. import { Descriptions } from 'antd';
  2. const Demo = () => (
  3. <div>
  4. <Descriptions
  5. title="Responsive Descriptions"
  6. bordered
  7. column={{ xxl: 4, xl: 3, lg: 3, md: 3, sm: 2, xs: 1 }}
  8. >
  9. <Descriptions.Item label="Product">Cloud Database</Descriptions.Item>
  10. <Descriptions.Item label="Billing">Prepaid</Descriptions.Item>
  11. <Descriptions.Item label="time">18:00:00</Descriptions.Item>
  12. <Descriptions.Item label="Amount">$80.00</Descriptions.Item>
  13. <Descriptions.Item label="Discount">$20.00</Descriptions.Item>
  14. <Descriptions.Item label="Official">$60.00</Descriptions.Item>
  15. <Descriptions.Item label="Config Info">
  16. Data disk type: MongoDB
  17. <br />
  18. Database version: 3.4
  19. <br />
  20. Package: dds.mongo.mid
  21. <br />
  22. Storage space: 10 GB
  23. <br />
  24. Replication factor: 3
  25. <br />
  26. Region: East China 1
  27. </Descriptions.Item>
  28. </Descriptions>
  29. </div>
  30. );
  31. ReactDOM.render(<Demo />, mountNode);

Descriptions描述列表 - 图5

垂直

垂直的列表。

  1. import { Descriptions } from 'antd';
  2. ReactDOM.render(
  3. <Descriptions title="User Info" layout="vertical">
  4. <Descriptions.Item label="UserName">Zhou Maomao</Descriptions.Item>
  5. <Descriptions.Item label="Telephone">1810000000</Descriptions.Item>
  6. <Descriptions.Item label="Live">Hangzhou, Zhejiang</Descriptions.Item>
  7. <Descriptions.Item label="Address" span={2}>
  8. No. 18, Wantang Road, Xihu District, Hangzhou, Zhejiang, China
  9. </Descriptions.Item>
  10. <Descriptions.Item label="Remark">empty</Descriptions.Item>
  11. </Descriptions>,
  12. mountNode,
  13. );

Descriptions描述列表 - 图6

垂直带边框的

垂直带边框和背景颜色的列表。

  1. import { Descriptions, Badge } from 'antd';
  2. ReactDOM.render(
  3. <Descriptions title="User Info" layout="vertical" bordered>
  4. <Descriptions.Item label="Product">Cloud Database</Descriptions.Item>
  5. <Descriptions.Item label="Billing Mode">Prepaid</Descriptions.Item>
  6. <Descriptions.Item label="Automatic Renewal">YES</Descriptions.Item>
  7. <Descriptions.Item label="Order time">2018-04-24 18:00:00</Descriptions.Item>
  8. <Descriptions.Item label="Usage Time" span={2}>
  9. 2019-04-24 18:00:00
  10. </Descriptions.Item>
  11. <Descriptions.Item label="Status" span={3}>
  12. <Badge status="processing" text="Running" />
  13. </Descriptions.Item>
  14. <Descriptions.Item label="Negotiated Amount">$80.00</Descriptions.Item>
  15. <Descriptions.Item label="Discount">$20.00</Descriptions.Item>
  16. <Descriptions.Item label="Official Receipts">$60.00</Descriptions.Item>
  17. <Descriptions.Item label="Config Info">
  18. Data disk type: MongoDB
  19. <br />
  20. Database version: 3.4
  21. <br />
  22. Package: dds.mongo.mid
  23. <br />
  24. Storage space: 10 GB
  25. <br />
  26. Replication factor: 3
  27. <br />
  28. Region: East China 1<br />
  29. </Descriptions.Item>
  30. </Descriptions>,
  31. mountNode,
  32. );

API

Descriptions

参数说明类型默认值版本
bordered是否展示边框booleanfalse
colon配置 Descriptions.Itemcolon 的默认值booleantrue
column一行的 DescriptionItems 数量,可以写成像素值或支持响应式的对象写法 { xs: 8, sm: 16, md: 24}number3
contentStyle自定义内容样式CSSProperties-4.10.0
extra描述列表的操作区域,显示在右上方ReactNode-4.5.0
labelStyle自定义标签样式CSSProperties-4.10.0
layout描述布局horizontal | verticalhorizontal
size设置列表的大小。可以设置为 middlesmall, 或不填(只有设置 bordered={true} 生效)default | middle | small-
title描述列表的标题,显示在最顶部ReactNode-

DescriptionItem

参数说明类型默认值版本
contentStyle自定义内容样式CSSProperties-4.9.0
label内容的描述ReactNode-
labelStyle自定义标签样式CSSProperties-4.9.0
span包含列的数量number1

span 是 Description.Item 的数量。 span={2} 会占用两个 DescriptionItem 的宽度。当同时配置 stylelabelStyle(或 contentStyle)时,两者会同时作用。样式冲突时,后者会覆盖前者。