Data display
Description List
Key/value rows inside a plain card (white, 1px border, radius 16, padding 20) for details and settings.
Preview
Details
- sarah.chen@ledgerly.com
- Phone
- +1 (415) 555-0142
- Location
- San Francisco, CA
- Owner
- Jordan Blake
"use client";
import { Pencil } from "lucide-react";
import { DescriptionList, PlainCard } from "@/components/ui/description-list";
import { IconButton } from "@/components/ui/icon-button";
export default function Example() {
return (
<PlainCard
title="Details"
className="w-full max-w-md"
actions={
<IconButton variant="ghost" size="xs" aria-label="Edit details">
<Pencil />
</IconButton>
}
>
<DescriptionList
items={[
{ label: "Email", value: "sarah.chen@ledgerly.com" },
{ label: "Phone", value: "+1 (415) 555-0142" },
{ label: "Location", value: "San Francisco, CA" },
{ label: "Owner", value: "Jordan Blake" },
]}
/>
</PlainCard>
);
}Installation
Components are copied into your project — no runtime package.
Create a
description-list.tsxfile and paste the following code into it.src/components/ui/description-list.tsximport type { ReactNode } from "react"; import { cx } from "@/utils/cx"; export interface DescriptionListProps { items: { label: string; value: ReactNode }[]; className?: string; } /** Key/value rows for detail panels: muted label column, primary value. */ export function DescriptionList({ items, className }: DescriptionListProps) { return ( <dl className={cx("grid grid-cols-[minmax(96px,auto)_1fr] gap-x-6 gap-y-3 text-base", className)}> {items.map((it) => ( <div key={it.label} className="contents"> <dt className="text-fg-muted">{it.label}</dt> <dd className="min-w-0 truncate text-fg">{it.value}</dd> </div> ))} </dl> ); } /** Plain card (white, 1px border, radius 16, padding 20) for details and settings. */ export function PlainCard({ title, actions, className, children }: { title?: ReactNode; actions?: ReactNode; className?: string; children: ReactNode }) { return ( <section className={cx("rounded-lg border border-line bg-surface p-5", className)}> {(title || actions) && ( <header className="mb-4 flex items-center justify-between gap-3"> <h3 className="text-base font-medium text-fg">{title}</h3> {actions} </header> )} {children} </section> ); }Add the theme tokens and the
cxhelper from Installation if you haven’t yet, then update the import paths to match your project setup.