Description List
Read-only label and value pairs for a detail page, in columns that wrap with the available width.
c2-description-list
Read-only key/value pairs for a detail page: the Descriptions of antd and the DescriptionList of Polaris. Each
c2-description-item child is one pair. The items flow into as many columns as fit, up to
--c2-description-list__grid--columns, each at least --c2-description-list__grid--min-column-width wide, so the
same markup is three columns on a wide page and one on a phone without a media query. An item spans the full row
with --c2-description-item--grid-column: 1 / -1.
Whether a label sits above its value or beside it is CSS too: --c2-description-item__label--width set to a
length puts the label beside the value, and the value still wraps under it when the item is narrower than the
label plus --c2-description-item__value--min-width. Set the item variables on the list and every item inherits them.
Items with several values (c2-description-value children) line up in columns; value-labels names those
columns in a header row and label-heading heads the label column. Style the row through --c2-description-list__value-header--*
(or the value-header part), or hide it with --c2-description-list__value-header--display: none. The header hides itself when the values stack,
and each value then shows its column name. A list with value columns lays its items out in a single column.
The list is exposed as a list and every item as a listitem holding a term and its definition.
<c2-description-list aria-label="Customer">
<c2-description-item label="Name">Ada Lovelace</c2-description-item>
<c2-description-item label="Email">ada@example.com</c2-description-item>
<c2-description-item label="Plan">Business</c2-description-item>
</c2-description-list>
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
value-labels | string[] | [] | Names of the value columns, for items with c2-description-value children. Separate them with ; in the attribute. |
label-heading | string | — | Heading of the label column, shown before the value-labels. |
Slots
| Name | Description |
|---|---|
(default) | The c2-description-item pairs. |
heading | Title shown above the pairs, such as <h3>Billing details</h3>. |
actions | Controls shown at the end of the header row, such as an Edit button. |
CSS parts
Shadow DOM styling hooks used with ::part(name). Prefer CSS custom properties when they cover the change.
| Name | Description |
|---|---|
header | The header row above the grid. It contains the heading slot and, at its end, the actions slot; hidden while both slots are empty. |
grid | The grid the items are laid out in. |
value-header | The row of column names drawn from value-labels, aligned with the items' value columns. Hidden while the values stack. |
CSS custom properties
Grouped by semantic target and state from --c2-<component>__<target>__<state>--<property>. Click a group to collapse it; click a name to copy it.
| Name | Type | Default | Description |
|---|---|---|---|
--c2-description-list__grid--columns | number | 3 | Most columns the items flow into. |
--c2-description-list__grid--min-column-width | pixel | 200px | Narrowest a column gets before the items wrap to fewer columns. |
--c2-description-list__grid--column-gap | pixel | 24px | |
--c2-description-list__grid--row-gap | pixel | 16px | |
--c2-description-list__container--padding | padding | 0px | |
--c2-description-list__container--border | border | none | |
--c2-description-list__container--border-radius | border-radius | 0px | |
--c2-description-list__container--background-color | color | transparent | |
--c2-description-list__container--font-family | font-family | inherit | |
--c2-description-list__header--gap | pixel | 12px | Space between the heading and the actions. |
--c2-description-list__header--margin-bottom | pixel | 16px | Space between the header and the pairs. |
--c2-description-list__header--padding | padding | 0px | |
--c2-description-list__header--border-bottom | border | none | |
--c2-description-list__header--color | color | #18181b | |
--c2-description-list__header--font-size | pixel | 16px | |
--c2-description-list__header--font-weight | font-weight | 600 | |
--c2-description-list__value-header--display | display | flex | none removes the row of column names; stacked values still show theirs. |
--c2-description-list__value-header--color | color | #18181b | |
--c2-description-list__value-header--font-size | pixel | 14px | |
--c2-description-list__value-header--font-weight | font-weight | 600 | |
--c2-description-list__value-header--padding-bottom | padding | 8px | |
--c2-description-list__value-header--border-bottom | border | 1px solid #e4e4e7 | |
--c2-description-list__value-header--margin-bottom | pixel | 0px | |
c2-description-item
One label and value pair of a c2-description-list. The label comes from the label attribute, or from the
label slot when it needs markup (an icon, a tooltip); the value is the item's content, which can be anything from
plain text to a badge, a link or an avatar. An item with no value shows empty-text, so a missing field reads as
"—" instead of an empty gap.
An item can hold several values, one c2-description-value each: the price of a feature in each plan, a metric
this month and last. They line up in equal columns across the items of the list, and the list's value-labels
names those columns. The layout adapts on its own: when the label and the columns no longer fit on one line the
columns move under the label, and when the columns themselves no longer fit (each narrower than
--c2-description-item__value-column--min-width) the values stack, each with its column name as a caption.
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
label | string | — | The label. The label slot takes its place when it has content. |
empty-text | string | — | Text shown while the value is empty. An empty string shows nothing. |
Slots
| Name | Description |
|---|---|
(default) | The value, or several c2-description-value elements for one value per column. |
label | Label content, used instead of the label attribute. |
actions | Controls shown after the value, such as a copy or edit button. |
CSS parts
Shadow DOM styling hooks used with ::part(name). Prefer CSS custom properties when they cover the change.
| Name | Description |
|---|---|
label | The label region (term). It wraps the label slot, whose fallback text is the label attribute. |
value | The value region (definition) around the default slot. With c2-description-value children it is the row of value columns instead. |
empty | The empty-text shown while the value is empty. |
actions | The wrapper around the actions slot, after the value. Hidden while the slot is empty. |
CSS custom properties
Grouped by semantic target and state from --c2-<component>__<target>__<state>--<property>. Click a group to collapse it; click a name to copy it.
| Name | Type | Default | Description |
|---|---|---|---|
--c2-description-item--grid-column | auto | Column placement in the list's grid. 1 / -1 spans the full row. | |
--c2-description-item__container--padding | padding | 0px | |
--c2-description-item__container--column-gap | pixel | 16px | Space between the label and the value when they sit side by side. |
--c2-description-item__container--row-gap | pixel | 4px | Space between the label and the value when the value sits under it. |
--c2-description-item__container--border-bottom | border | none | Divider under each item. |
--c2-description-item__container--background-color | color | transparent | |
--c2-description-item__label--width | pixel | 100% | A length such as 160px puts the label beside the value; 100% puts it above. |
--c2-description-item__label--color | color | #71717a | |
--c2-description-item__label--font-size | pixel | 14px | |
--c2-description-item__label--font-weight | font-weight | 400 | |
--c2-description-item__label--line-height | 20px | ||
--c2-description-item__value--min-width | pixel | 0px | Narrowest the value gets beside its label before it wraps under it. |
--c2-description-item__value--color | color | #18181b | |
--c2-description-item__value--font-size | pixel | 14px | |
--c2-description-item__value--font-weight | font-weight | 500 | |
--c2-description-item__value--line-height | 20px | ||
--c2-description-item__value--overflow-wrap | anywhere | How a long unbroken value (an ID, a URL) wraps. | |
--c2-description-item__value-column--min-width | pixel | 120px | Narrowest a c2-description-value column gets before the values stack. |
--c2-description-item__value-column--gap | pixel | 16px | Space between c2-description-value columns. |
--c2-description-item__value-column--row-gap | pixel | 6px | Space between stacked c2-description-value rows. |
--c2-description-item__empty--color | color | #71717a | |
--c2-description-item__actions--gap | pixel | 4px | |
c2-description-value
One value of a c2-description-item that has several, such as a plan's price in each of three plans. Values line
up in columns across the items of a list, and the list's value-labels names the columns. When the columns no
longer fit, the values stack under their label and each one shows its column name as a caption; the caption is
always there for assistive technology, which reads it with the value.
Slots
| Name | Description |
|---|---|
(default) | The value. |
CSS parts
Shadow DOM styling hooks used with ::part(name). Prefer CSS custom properties when they cover the change.
| Name | Description |
|---|---|
caption | The column name before the value. It is shown only while the values are stacked, and visually hidden otherwise. |
content | The wrapper around the default slot, which holds the value. |
CSS custom properties
Grouped by semantic target and state from --c2-<component>__<target>__<state>--<property>. Click a group to collapse it; click a name to copy it.
| Name | Type | Default | Description |
|---|---|---|---|
--c2-description-value__caption--display | display | block | none removes the column name, for screen readers too, so the stacked values show alone. |
--c2-description-value__caption--width | pixel | 40% | Width of the caption beside a stacked value. |
--c2-description-value__caption--color | color | #71717a | |
--c2-description-value__caption--font-size | pixel | 12px | |
--c2-description-value__caption--font-weight | font-weight | 600 | |