Skip to main content

Descriptions

Grouped key-value display (label + content) with per-row column count, column spanning, and a bordered table layout. Structurally identical to lh-ui-plus's LhDescriptions: plus's items array specializes into the LhDescriptionsItem child component in React, and row normalization shares the same pure functions from share core.

Basic usage​

Basic usage
Artwork profile
Artwork
Spring River Panorama
Artist
Mobai
Year
Bingwu year
Style
Xieyi (freehand)
Notes
Distant mountains are washed in light ink while the foreground is dotted with thick ink — void and solid echo each other.
Bordered (two columns)
Artwork
Spring River Panorama
Artist
Mobai
Notes
Distant mountains are washed in light ink while the foreground is dotted with thick ink — void and solid echo each other.
import { LhDescriptions, LhDescriptionsItem } from '@lh-ui/react'

export default function Demo() {
return (
<LhDescriptions title="Artwork profile">
<LhDescriptionsItem label="Artwork">Spring River Panorama</LhDescriptionsItem>
<LhDescriptionsItem label="Artist">Mobai</LhDescriptionsItem>
<LhDescriptionsItem label="Style">Xieyi (freehand)</LhDescriptionsItem>
<LhDescriptionsItem label="Notes" span={2}>
Distant mountains washed in light ink, foreground dotted with thick ink.
</LhDescriptionsItem>
</LhDescriptions>
)
}

Bordered layout and spanning​

border switches to the table layout; column sets the number of item columns per row; an item's span spans columns — values beyond the remaining width of the current row are clamped to it, full rows wrap automatically, and the last row is padded to full width by a placeholder.

import { LhDescriptions, LhDescriptionsItem } from '@lh-ui/react'

export default function Demo() {
return (
<LhDescriptions title="Bordered (two columns)" border column={2}>
<LhDescriptionsItem label="Artwork">Spring River Panorama</LhDescriptionsItem>
<LhDescriptionsItem label="Artist">Mobai</LhDescriptionsItem>
<LhDescriptionsItem label="Notes" span={2}>Light ink afar, dense dots nearby.</LhDescriptionsItem>
</LhDescriptions>
)
}

API mapping from plus​

plus's items data array and slots merge into the child-component form in React:

plusReact
The label / value / span triple of the items array<LhDescriptionsItem label span>Content</LhDescriptionsItem>
The #title named slotThe title prop (ReactNode)
The item-* scoped slots (custom item content)The children of LhDescriptionsItem (ReactNode)

LhDescriptions Props​

PropDescriptionTypeDefault
titleDescription list title (ReactNode, merging plus's #title slot)ReactNode—
columnNumber of item columns per rownumber3
borderWhether to show the borderbooleanfalse
sxShorthand layout propsSxProps—

LhDescriptionsItem Props​

PropDescriptionTypeDefault
labelItem label (rendered as <dt>)string—
spanNumber of columns occupied (clamped when exceeding column or the remaining width)number1
childrenItem content (rendered as <dd>, merging plus's value and the per-item scoped slot)ReactNode—

Row layout and spanning rules​

Rows are normalized by the share core pure function buildDescriptionRows (same source as plus): span defaults to 1, invalid values (non-numbers / ≤ 0) are treated as 1; values beyond the remaining width of the current row are clamped to it (at least 1 column); full rows wrap automatically; the last incomplete row is padded to full width by the lh-descriptions__filler placeholder.

Item collection

Items are collected via React.Children: Fragment grouping and conditional rendering ({cond && <LhDescriptionsItem />}) are both flattened, and children that are not LhDescriptionsItem are ignored. LhDescriptionsItem is a descriptor component that renders no DOM itself — row layout and span clamping must be computed a whole row at a time, so the dl / dt / dd structure is rendered by LhDescriptions.

Accessibility​

Semantic description-list structure: each row is a <dl> with labels as <dt> and content as <dd>, read by screen readers with description-list semantics; the padding placeholder carries aria-hidden="true" and is removed from the screen-reader tree. The UA default margins of dl / dt / dd are reset by the style source so they never disturb the flex rows.

ref​

forwardRef<HTMLDivElement> — the root element. LhDescriptionsItem is a descriptor component: it renders no DOM and does not forward a ref.

Styles​

import '@lh-ui/react/theme.css'
import '@lh-ui/react/style/descriptions'