KeyValueList
Labelled facts, one per row.
Overview
A set of facts about one thing: size, status, dates, shortcut keys.
Facts list
Do
- Size
- 1280×720
- Changed pixels
- 0.4%
- Captured
- 2 min ago
import { KeyValue, KeyValueList } from "@hackcove/ui";
<KeyValueList>
<KeyValue label="Size">1280×720</KeyValue>
<KeyValue label="Changed pixels">0.4%</KeyValue>
<KeyValue label="Captured">2 min ago</KeyValue>
</KeyValueList>KeyValueList: one row per fact, the label muted, the value in tabular figures.Don't
Size1280×720
Changed pixels0.4%
import { Body, Cluster, Stack } from "@hackcove/ui";
<Stack gap="xs">
<Cluster justify="between">
<Body>Size</Body>
<Body>1280×720</Body>
</Cluster>
<Cluster justify="between">
<Body>Changed pixels</Body>
<Body>0.4%</Body>
</Cluster>
</Stack>Cluster and Body drift from the list's label colour and figures. Use KeyValueList.Align start
Do
- Branch
- hc-145-docs-for-every-export
- Commit
- 83422a6
- Captured
- 2 min ago
import { KeyValue, KeyValueList } from "@hackcove/ui";
<KeyValueList align="start">
<KeyValue label="Branch">hc-145-docs-for-every-export</KeyValue>
<KeyValue label="Commit">83422a6</KeyValue>
<KeyValue label="Captured">2 min ago</KeyValue>
</KeyValueList>align="start" puts the values in one left-aligned column, for long values or a mix of short and long ones.Usage
- Put a
KeyValuewith alabelfor each fact; the value is its children. align="end"is the default: each label at the left and its value right-aligned.align="start"puts every value left-aligned in one column beside the labels, which suits long values.- A value can be any content, such as a
Kbdfor a shortcut. - Do not build the rows by hand from a
Cluster; a grid of records is aTable.
Accessibility
KeyValueListis a<dl>; eachKeyValueis a<div>holding a<dt>for the label and a<dd>for the value, so a screen reader announces them as terms and definitions.id,data-*andaria-*go on the list and on each row.
API
KeyValueList
A definition list of label/value rows. By default each label is on the left and its value right-aligned. align="start" puts every value left-aligned in one column beside the labels, which are sized to the widest.
align- Type
"end" | "start"- Default
end
KeyValue
One row of a KeyValueList: a label on the left, a tabular value on the right (or beside it, in an align="start" list).
label required- Type
ReactNode