Key Value
Compound component for displaying labeled data. KeyValue wraps one or more KeyValue.Item rows in a semantic description list.
Installation
dgadd ships in @diffgazer/add on npm: pnpm add -D @diffgazer/add puts it on pnpm exec, and npx @diffgazer/add runs it without the install.
UI components require Tailwind CSS v4. Local copy mode imports src/styles/styles.css; package mode uses @diffgazer/ui CSS from the installed package.
Usage
Examples
Variants
Description
Bordered
List
API Reference
KeyValue
KeyValue.Item
Accessibility
Notes
When to use KeyValue vs Label
Use KeyValue for structured multi-row data display (metadata panels, commit info). Use Label for form field labeling.
Compound Usage
Always wrap KeyValue.Item inside KeyValue — this produces a proper <dl> list. For a single pair: <KeyValue><KeyValue.Item label='...' value='...' /></KeyValue>.
Color Variants
5 semantic color variants (default, warning, info, success, error) style the value text. The info variant renders monospace in the info color instead of bold.
Bordered Rows
Set bordered on KeyValue or KeyValue.Item to add top separators between rows, vertical padding, and compact text-xs sizing — ideal for stacked list layouts.
Layout Options
Horizontal layout (default) places label and value side-by-side. Vertical layout stacks them with a small gap. Both label and value accept ReactNode.
Descriptions
Pass description to qualify a pair with a line of muted copy. It renders as a second <dd> for the same <dt>, spanning the full row in horizontal layout — so callers never have to restate the grid's column count.
Class Slots
KeyValue.Item renders up to three elements: className (and every other forwarded prop) lands on the <dt>, valueClassName on the value <dd>, descriptionClassName on the description <dd>. All preserve the <dl>/<dt>/<dd> structure.
Source
Install via CLI: pnpm exec dgadd add ui/key-value.
Highlighted source loads after this disclosure opens. Browse the source repository.