diff --git a/components/descriptions/Row.tsx b/components/descriptions/Row.tsx index 3d7662e1de..02f86017c5 100644 --- a/components/descriptions/Row.tsx +++ b/components/descriptions/Row.tsx @@ -1,6 +1,7 @@ import * as React from 'react'; import { DescriptionsItemProps } from './Item'; import Cell from './Cell'; +import { DescriptionsContext, DescriptionsContextProps } from '.'; interface CellConfig { component: string | [string, string]; @@ -12,7 +13,14 @@ interface CellConfig { function renderCells( items: React.ReactElement[], { colon, prefixCls, bordered }: RowProps, - { component, type, showLabel, showContent }: CellConfig, + { + component, + type, + showLabel, + showContent, + labelStyle: rootLabelStyle, + contentStyle: rootContentStyle, + }: CellConfig & DescriptionsContextProps, ) { return items.map( ( @@ -37,8 +45,8 @@ function renderCells( key={`${type}-${key || index}`} className={className} style={style} - labelStyle={labelStyle} - contentStyle={contentStyle} + labelStyle={{ ...rootLabelStyle, ...labelStyle }} + contentStyle={{ ...rootContentStyle, ...contentStyle }} span={span} colon={colon} component={component} @@ -54,7 +62,7 @@ function renderCells( = props => { + const descContext = React.useContext(DescriptionsContext); + const { prefixCls, vertical, row, index, bordered } = props; if (vertical) { return ( <> - {renderCells(row, props, { component: 'th', type: 'label', showLabel: true })} + {renderCells(row, props, { + component: 'th', + type: 'label', + showLabel: true, + ...descContext, + })} {renderCells(row, props, { component: 'td', type: 'content', showContent: true, + ...descContext, })} @@ -112,6 +128,7 @@ const Row: React.FC = props => { type: 'item', showLabel: true, showContent: true, + ...descContext, })} ); diff --git a/components/descriptions/__tests__/__snapshots__/demo.test.js.snap b/components/descriptions/__tests__/__snapshots__/demo.test.js.snap index 2ffd3aed1b..1545113e7a 100644 --- a/components/descriptions/__tests__/__snapshots__/demo.test.js.snap +++ b/components/descriptions/__tests__/__snapshots__/demo.test.js.snap @@ -960,6 +960,165 @@ Array [ , +