Key-value list
FreeGrey labels over their values, as a row's detail shows what an agent did: who started it, who approved it, through which tool, and the result.
npx shadcn@latest add https://pixilui.com/r/key-value-list.jsonPreview
Label and value pairs that wrap long values without breaking the grid.
import { StatusDot } from "@/components/pixilui/status-dot";
import { KeyValueList } from "@/components/pixilui/key-value-list";
// One finished element: the record is the data.
export const knobs = {} as const;
/** What an agent's refund did, as the activity log's detail shows it. */
export default function KeyValueListDemo() {
return (
<div className="w-full max-w-md rounded-panel bg-surface p-6 elevation-raised">
<KeyValueList
items={[
{ label: "Started by", value: "Support agent, on the refund rule Maya Rao set" },
{ label: "Approved by", value: "Maya Rao" },
{ label: "Through", value: "Stripe" },
{ label: "Did", value: "Refunded the duplicate charge of $600.00" },
{
label: "Result",
value: (
<>
<StatusDot state="done" size="sm" />
Refund sent, 5 to 10 days to arrive
</>
),
},
]}
/>
</div>
);
}When to use
Use it when
- Inside a list row's detail: Agents read, Connected by; Started by, Approved by, Through, Did, Result.
- A short spec of a record in a panel or a card.
Use something else when
- Many records with the same fields: use the sortable table.
- Editable settings: use fields.
Installation
Terminal
npx shadcn@latest add https://pixilui.com/r/key-value-list.jsonAdds key-value-list.tsx, and installs clsx and tailwind-merge. The URL works in any app with a components.json, with no registry to add first.
components/pixilui/key-value-list.tsx
"use client";
import { forwardRef, type ComponentPropsWithoutRef, type ReactNode } from "react";
import { cn } from "./lib/utils";
/** A missing list prop (plain JavaScript, a guessing agent): one stable empty list, so nothing throws or re-renders. */
const NONE: never[] = [];
/*
Key-value list (B12, locked 1 Dec 2026 with the rows): grey labels over their values, as a row's detail shows what an agent
did ("Approved by", "Through", "Result"). The locked .list-kv, foundation.css section 8.
*/
/** One pair: the grey label, and its value (text, or a logo or status node with words). */
export type KeyValueItem = { label: ReactNode; value: ReactNode; id?: string };
export type KeyValueListProps = Omit<ComponentPropsWithoutRef<"dl">, "children"> & {
/** The pairs, in order. */
items: KeyValueItem[];
};
/** Label and value rows: the labels grey, the values in ink, long values wrapping without breaking the grid. */
export const KeyValueList = forwardRef<HTMLDListElement, KeyValueListProps>(function KeyValueList({ items = NONE, className, ...rest }, ref) {
return (
<dl ref={ref} className={cn("pixilui-list-kv font-body", className)} {...rest}>
{items.map((item, i) => (
<div key={item.id ?? i}>
<dt>{item.label}</dt>
<dd>{item.value}</dd>
</div>
))}
</dl>
);
});
Then npm i clsx tailwind-merge, and add the foundation once per app, as in Installation.
Usage
example.tsx
import { KeyValueList } from "@/components/pixilui/key-value-list";
<KeyValueList items={items} />Fills its container; long values wrap under their label.
API reference
PropTypeDefault
itemsRequiredKeyValueItem[]NONEThe pairs, in order.Also takes every native <dl> attribute, and a ref.
Keyboard
TabNever takes focus itself; links or buttons inside a value do.
Accessibility
- A description list (dl, dt, dd), so each value is read with its label.
- Labels are grey but pass contrast on their surface.
Motion
- None of its own; it folds with the row that holds it.