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
- 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.
- 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:
| plus | React |
|---|---|
The label / value / span triple of the items array | <LhDescriptionsItem label span>Content</LhDescriptionsItem> |
The #title named slot | The title prop (ReactNode) |
The item-* scoped slots (custom item content) | The children of LhDescriptionsItem (ReactNode) |
LhDescriptions Props
| Prop | Description | Type | Default |
|---|---|---|---|
| title | Description list title (ReactNode, merging plus's #title slot) | ReactNode | — |
| column | Number of item columns per row | number | 3 |
| border | Whether to show the border | boolean | false |
| sx | Shorthand layout props | SxProps | — |
LhDescriptionsItem Props
| Prop | Description | Type | Default |
|---|---|---|---|
| label | Item label (rendered as <dt>) | string | — |
| span | Number of columns occupied (clamped when exceeding column or the remaining width) | number | 1 |
| children | Item 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.
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'