JGuang

Descriptions

Descriptions · Ant Design

Preview
npm install antd@6.6.5 @ant-design/icons@6.3.4 dayjs@1.11.23

Descriptions

Display multiple read-only fields in a group.

When To Use

Commonly displayed on the details page.

// works when >= 5.8.0, recommended ✅

const items: DescriptionsProps['items'] = [
  {
    key: '1',
    label: 'UserName',
    children: <p>Zhou Maomao</p>,
  },
  {
    key: '2',
    label: 'Telephone',
    children: <p>1810000000</p>,
  },
  {
    key: '3',
    label: 'Live',
    children: <p>Hangzhou, Zhejiang</p>,
  },
  {
    key: '4',
    label: 'Remark',
    children: <p>empty</p>,
  },
  {
    key: '5',
    label: 'Address',
    children: <p>No. 18, Wantang Road, Xihu District, Hangzhou, Zhejiang, China</p>,
  },
];

<Descriptions title="User Info" items={items} />;

// works when <5.8.0 , deprecated when >=5.8.0 🙅🏻‍♀️

<Descriptions title="User Info">
  <Descriptions.Item label="UserName">Zhou Maomao</Descriptions.Item>
  <Descriptions.Item label="Telephone">1810000000</Descriptions.Item>
  <Descriptions.Item label="Live">Hangzhou, Zhejiang</Descriptions.Item>
  <Descriptions.Item label="Remark">empty</Descriptions.Item>
  <Descriptions.Item label="Address">
    No. 18, Wantang Road, Xihu District, Hangzhou, Zhejiang, China
  </Descriptions.Item>
</Descriptions>;

Examples

  • Basic · basic

  • border · border

  • Custom size · size

  • responsive · responsive

  • Vertical · vertical

  • Vertical border · vertical-border

  • Custom semantic dom styling · style-class

  • row · block

API

Common props ref:Common props

Descriptions

PropertyDescriptionTypeDefaultVersionGlobal Config
borderedWhether to display the borderbooleanfalse×
classNamesCustomize class for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, string> | (info: { props })=> Record<SemanticDOM, string>-5.23.0
colonChange default props colon value of Descriptions.Item. Indicates whether the colon after the label is displayedbooleantrue×
columnThe number of DescriptionItems in a row, could be an object (like { xs: 8, sm: 16, md: 24}, but must have bordered={true}) or a numbernumber | Record<Breakpoint, number>3×
contentStyleCustomize content style, Please use styles.content insteadCSSProperties-4.10.0×
extraThe action area of the description list, placed at the top-rightReactNode-4.5.0×
itemsDescribe the contents of the list itemDescriptionsItem[]-5.8.0×
labelStyleCustomize label style, Please use styles.label insteadCSSProperties-4.10.0×
layoutDefine description layouthorizontal | verticalhorizontal×
sizeSet the size of the list. Can be set to medium,small, or not filledlarge | medium | smalllarge×
stylesCustomize inline style for each semantic structure inside the component. Supports object or function.Record<SemanticDOM, CSSProperties> | (info: { props })=> Record<SemanticDOM, CSSProperties>-5.23.0
titleThe title of the description list, placed at the topReactNode-×

DescriptionItem

PropertyDescriptionTypeDefaultVersion
contentStyleCustomize content style, Please use styles.content insteadCSSProperties-4.9.0
labelThe description of the contentReactNode-
labelStyleCustomize label style, Please use styles.label insteadCSSProperties-4.9.0
spanThe number of columns included(filled Fill the remaining part of the current row)number | filled | Screens1screens: 5.9.0, filled: 5.22.0

The number of span Description.Item. Span={2} takes up the width of two DescriptionItems. When both style and labelStyle(or contentStyle) configured, both of them will work. And next one will overwrite first when conflict.

Semantic DOM

Semantic nodeNative descriptionVersion
rootRoot element with basic styles, reset styles, border styles, layout direction and other overall styles for description list container5.23.0
headerHeader element with flex layout, alignment, bottom margin and other layout and style controls for header area5.23.0
titleTitle element with text ellipsis, flex ratio, color, font weight, font size, line height and other title text styles5.23.0
extraExtra content element with left margin, color, font size and other styles for additional operation area5.23.0
labelLabel element with color, font weight, font size, line height, text align, colon styles and other label text styles5.23.0
contentContent element with table cell layout, color, font size, line height, word break and other content display styles5.23.0

Semantic description source: vendor/components/descriptions/demo/_semantic.tsx

Design Token

Types, inheritance and declarations retain the pinned native source. Defaults are computed by the native theme and may be overridden by ConfigProvider; this table does not invent static defaults.

TokenTypeNative description
labelBgstringBackground color of label
labelColorstringText color of label
titleColorstringText color of title
titleMarginBottomnumberBottom margin of title
itemPaddingBottomnumberBottom padding of item
itemPaddingEndnumberEnd padding of item
colonMarginRightnumberRight margin of colon
colonMarginLeftnumberLeft margin of colon
contentColorstringText color of content
extraColorstringText color of extra area

Declaration source: vendor/components/descriptions/style/index.ts

import { unit } from '@ant-design/cssinjs';

import type { CSSObject } from '@ant-design/cssinjs';

import { resetComponent, textEllipsis } from '../../style';

import type { FullToken, GenerateStyle, GetDefaultToken } from '../../theme/internal';

import { genStyleHooks, mergeToken } from '../../theme/internal';

/** Component only token. Which will handle additional calculation of alias token */
export interface ComponentToken {
  // Component token here
  /**
   * @desc 标签背景色
   * @descEN Background color of label
   */
  labelBg: string;
  /**
   * @desc 标签文字颜色
   * @descEN Text color of label
   */
  labelColor: string;
  /**
   * @desc 标题文字颜色
   * @descEN Text color of title
   */
  titleColor: string;
  /**
   * @desc 标题下间距
   * @descEN Bottom margin of title
   */
  titleMarginBottom: number;
  /**
   * @desc 子项下间距
   * @descEN Bottom padding of item
   */
  itemPaddingBottom: number;
  /**
   * @desc 子项结束间距
   * @descEN End padding of item
   */
  itemPaddingEnd: number;
  /**
   * @desc 冒号右间距
   * @descEN Right margin of colon
   */
  colonMarginRight: number;
  /**
   * @desc 冒号左间距
   * @descEN Left margin of colon
   */
  colonMarginLeft: number;
  /**
   * @desc 内容区域文字颜色
   * @descEN Text color of content
   */
  contentColor: string;
  /**
   * @desc 额外区域文字颜色
   * @descEN Text color of extra area
   */
  extraColor: string;
}

interface DescriptionsToken extends FullToken<'Descriptions'> {}

Shared native props

Tips: The following generic properties apply to most antd components; those not supported are described separately.

PropertyDescriptionTypeDefault
styleThe additional styleCSSProperties-
classNameThe additional css classstring-
rootClassNameClassName on the root elementstring-
autoFocusAuto focus when component mounted, only effective for focusable elements like forms, links, etc.booleanfalse

Install and reproduce an example

npm install antd@6.6.5 @ant-design/icons@6.3.4 dayjs@1.11.23

Use ConfigProvider and native App; configure dayjs locale separately. Each example lists its complete source files and additional pinned dependencies in View code. Example names select demos, not universal component props. See the resource setup guide for theme, locale and SSR.

Native type references

The source viewer includes unchanged native implementations and the following source declarations. Inherited types remain in their native packages. English source comments are preserved as code reference.

  • vendor/components/descriptions/Cell.tsx
  • vendor/components/descriptions/DescriptionsContext.ts
  • vendor/components/descriptions/Item.ts
  • vendor/components/descriptions/Row.tsx
  • vendor/components/descriptions/index.tsx
  • vendor/components/descriptions/style/index.ts

Source and license

https://github.com/ant-design/ant-design/tree/4a39f54842eade4e565ab336ef6097cd7e723cdd

Original bilingual prose and executable examples are retained. Website-only embeds and token tables are expanded locally. Ant Design is MIT; separately listed dependency notices also apply. Upload previews block outbound requests and do not provide a backend.