Skip to content

DataList

A list of things and what they are called: a details panel, a summary of a record, the metadata under a heading. Real <dt>/<dd> pairs, so each row is read as "label, value".

tsx
import { DataList, DataListItem } from 'neba';

<DataList>
  <DataListItem label="Status">Live</DataListItem>
  <DataListItem label="Region">Frankfurt</DataListItem>
</DataList>;

Props

PropTypeDefaultDescription
orientationshared'horizontal' | 'vertical''horizontal'Where the label sits. Horizontal is a column of its own beside the value, vertical is above it
labelWidthnumber | stringHow wide the label column is when horizontal. Numbers are pixels; left out it is as wide as the widest label
dividersbooleanfalseDraws a hairline between the rows
sizeshared'xs' | 'sm' | 'md' | 'lg' | 'xl''md'The type scale of the labels and the values
densityshared'default' | 'compact''default'Changes the gaps between rows and columns, and nothing else
childrenReactNodeThe rows

Every native <dl> attribute passes through, apart from color. It draws no surface: put it in a Card or a Box when one is wanted.

Not a two-column Table. A table is a grid of rows all of the same shape, walked as a grid; this is a set of pairs, each read as a label and its value.

DataListItem

PropTypeDefaultDescription
label * ReactNodeWhat the value is called. Rendered as the dt
childrenReactNodeThe value. A node, so a Chip, a link or a piece of code all fit. Rendered as the dd

Examples

orientation

horizontal puts the label in a column of its own beside the value, which is the shape a details panel takes. vertical puts it above: for a narrow column, and for values long enough that a label beside them would leave most of the row empty.

labelWidth

Left out, the label column is as wide as the widest label, which is what makes every value start at the same place. Set it to hold two lists side by side to the same measure.

dividers

A hairline between the rows, for a long list where the pairs need separating.

Accessibility

  • Renders a real <dl> with each pair as a <dt> and a <dd>, so the label and the value are associated without any ARIA.
  • A value can be any node (a Chip, a TextLink, an Avatar), and keeps whatever semantics it brought.

Released under the MIT License