# Key-value list

Grey 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.

Tier: free. Type: component. Category: data. Tags: agent, approval.

## Install

```bash
npx shadcn@latest add https://pixilui.com/r/key-value-list.json
```

One-time setup: add the registry to `components.json`:

```json
{
  "registries": {
    "@pixilui": "https://pixilui.com/r/{name}.json"
  }
}
```

Files: `components/pixilui/key-value-list.tsx`.

## Preview

Live preview: https://pixilui.com/components/key-value-list

Signature: Fold out an agent's step and its record reads in two tones: Approved by, Maya Rao; Through, Stripe.

Styles: `lively` (default), `quiet`, set with `data-style` on <html>. The item reads the style through the foundation; it needs no prop. Standalone files: lively https://pixilui.com/r/standalone/key-value-list.tsx, quiet https://pixilui.com/r/standalone/key-value-list.quiet.tsx.

## Code

`components/pixilui/key-value-list.tsx`

```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>
  );
});
```

## Usage

When to use:

- 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.

When not to use:

- Many records with the same fields: use the sortable table.
- Editable settings: use fields.

```tsx
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>
  );
}
```

## Examples

None.

## API

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `items` (required) | `KeyValueItem[]` | `NONE` | The pairs, in order. |

Also accepts every native `<dl>` attribute, and a ref to it.

## Keyboard

- `Tab`: Never 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.

## Responsive

- Fills its container; long values wrap under their label.

## Performance

- CSS in the foundation (section 8).

## Notes for AI

- <KeyValueList items={[{ label: "Approved by", value: "Maya Rao" }, { label: "Result", value: <><StatusDot state="done" size="sm" />Refund sent</> }]} />.
- Put it in a ListRow's detail to fold it out under the row.
- Per-style rule: none; it wears the rows' quiet values through its list.

## Related

- [List row](https://pixilui.com/components/list-row/markdown): The dense row every list shares: a status node, avatar or logo, a title with one grey line, and a value or time. Runs shimmer while they work, open from the keyboard and fold out to show the work.
- [Sortable table](https://pixilui.com/components/sortable-table/markdown): Records in columns: click a header and the rows glide into order, numbers line up at the end, and picked rows raise a bulk bar that counts them. Airy in lively, compact lines in quiet.
