@dax-ui/detail-field
v0.8.0
Published
dax-ui DetailField: read-only label + value fields, titled sections and responsive grids for detail views
Maintainers
Readme
@dax-ui/detail-field
Read-only details, the way a "view" modal or page shows a record: DetailField is a small
muted label with an icon and the value below it; DetailSection groups fields under a
colored title with a line running to the right; DetailGrid lays fields out in responsive
columns. Values can be anything (text, chips, links); empty values show a placeholder,
loading values a skeleton, and text values can be copied.
Installation
pnpm add @dax-ui/detail-fieldMUI and Emotion are included; the app only needs React 18 or 19.
One-time setup per app (skip if the app already uses dax-ui): install
@dax-ui/theme and wrap the app in its UIProvider.
pnpm add @dax-ui/themeAny icon component works; the examples use lucide-react.
Usage
import { DetailField, DetailGrid, DetailSection } from '@dax-ui/detail-field';
import { Chip } from '@dax-ui/chip';
import { CalendarDays, Clock, FileText, LayoutGrid, MapPin } from 'lucide-react';
<DetailSection title="General Information">
<DetailGrid>
<DetailField label="Site" value="PK-nineToFive" icon={<MapPin />} copyable />
<DetailField label="Title" value="qwrwq" icon={<FileText />} />
<DetailField label="Event Type" value="Meeting" icon={<LayoutGrid />} />
<DetailField label="Priority" value={<Chip label="Medium" color="success" dot />} />
</DetailGrid>
</DetailSection>
<DetailSection title="Schedule" action={<Button size="sm" variant="ghost">Edit</Button>}>
<DetailGrid>
<DetailField label="Date" value="Nov 1, 2026" icon={<CalendarDays />} span="full" />
<DetailField label="Start Time" value={start} icon={<Clock />} loading={isLoading} />
<DetailField label="End Time" value={end} icon={<Clock />} loading={isLoading} />
</DetailGrid>
</DetailSection>
// Empty, custom colors, side by side
<DetailField label="Department" value={null} emptyValue="Not set" />
<DetailField label="Owner" value="Amina" labelColor="#0f766e" iconColor="#0f766e" icon={<UserIcon />} />
<DetailField label="Created" value="Nov 2, 2026" orientation="inline" labelWidth={120} />Inside a DetailGrid (a <dl>), fields render as <dt>/<dd> pairs; elsewhere as plain
<div>s. DetailSection is a <section> named by its heading (h3 by default, see
headingLevel).
Customizing
- Colors:
labelColor,valueColor,iconColor, orcolors(label,value,icon,empty,accent) on a field;titleColor,lineColororcolorson a section. They're CSS variables (--dax-detail-field-<key>,--dax-detail-section-<key>), so setting one on an ancestor recolors every field inside it. Defaults follow light and dark mode (DEFAULT_DETAIL_FIELD_COLORS,DEFAULT_DETAIL_SECTION_COLORSand their_DARK_twins). - Sizes:
sizesm,mdorlg;orientationstackedorinline. - Layout:
span(columns, or'full'),maxLines,helperText,action. - Anything else:
sxon every component, andslotProps.label/.value/.iconon a field.
Props
DetailField
| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| label (required) | ReactNode | | What the value is, e.g. "Site". Shown small and muted above (or beside) the value. |
| action | ReactNode | | Shown at the end of the value row, e.g. an edit link or a small button. |
| children | ReactNode | | The value, when it reads better as children. value wins if both are set. |
| className | string | | Class name on the root element. |
| colors | Partial<DetailFieldColors> | | Overrides any of the field's colors. labelColor, valueColor and iconColor are shorthands that win over these. Unset keys keep the defaults (which follow light and dark mode). |
| copyable | string \| boolean | false | Adds a button that copies the value to the clipboard. true copies the value when it's text or a number; a string copies that string instead (e.g. a full ID behind a short label). |
| copyLabel | string | 'Copy <label>' (or 'Copy' when the label isn't text) | Accessible name of the copy button. |
| emptyValue | ReactNode | — | Shown when the value is empty. |
| helperText | ReactNode | | Small muted text under the value, e.g. a hint or a timestamp. |
| icon | ReactNode | | Icon before the label, e.g. <MapPinIcon />. Decorative: hidden from screen readers. |
| iconColor | string | | Icon color. Shorthand for colors.icon. |
| id | string | | Id of the root element. |
| labelColor | string | | Label color, e.g. '#0f766e'. Shorthand for colors.label. |
| labelWidth | string \| number | 160 | Width of the label with orientation="inline", in px or any CSS length. |
| loading | boolean | false | Shows a skeleton in place of the value while it loads, and marks the field aria-busy. |
| loadingLines | number | 1 | Number of skeleton lines while loading, for long values. |
| maxLines | number | | Cuts the value off after this many lines, ending in "…". |
| onCopy | ((text: string) => void) | | Called with the copied text after a successful copy. |
| orientation | "stacked" \| "inline" | stacked | stacked puts the value under the label; inline puts them side by side, the label labelWidth wide. |
| size | "sm" \| "md" \| "lg" | md | Text sizes: sm (12px label, 14px value), md (14 / 16) or lg (15 / 19). |
| slotProps | { label?: DetailFieldSlotProps; value?: DetailFieldSlotProps; icon?: DetailFieldSlotProps \| undefined; } \| undefined | {} | Extra props and sx for the parts: label, value and icon. |
| span | number \| "full" | 1 | Inside a DetailGrid: how many columns the field spans; 'full' spans the whole row (e.g. a description). |
| style | CSSProperties | | Inline styles on the root element. |
| sx | SxProps<Theme> | | Style overrides on the root element. |
| value | ReactNode | | The value: text, a number, chips, a link, anything. Falls back to children; when both are empty (null, undefined, '' or an empty array), emptyValue is shown. |
| valueColor | string | | Value color. Shorthand for colors.value. |
DetailSection
| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| title (required) | ReactNode | | Section title, e.g. "General Information". |
| action | ReactNode | | Shown at the right end of the title row, e.g. an "Edit" button. |
| children | ReactNode | | The section's content: usually a DetailGrid of fields. |
| className | string | | Class name on the root element. |
| collapsed | boolean | | Whether a collapsible section is collapsed. Pair with onCollapsedChange to control it. |
| collapsible | boolean | false | Makes the title a button that shows and hides the content. |
| colors | Partial<DetailSectionColors> | | Overrides any of the section's colors. Unset keys keep the defaults. |
| defaultCollapsed | boolean | false | Initial state of a collapsible section when collapsed isn't controlled. |
| description | ReactNode | | Muted text under the title. |
| gap | string \| number | 20 | Space between the title row and the content, in px or any CSS length. |
| headingLevel | 2 \| 3 \| 4 \| 5 \| 6 | 3 | Heading level of the title (h2…h6), to fit the page's outline. |
| hideLine | boolean | false | Hides the line extending to the right of the title. |
| icon | ReactNode | | Icon before the title. Decorative: hidden from screen readers. |
| id | string | | Id of the root element. |
| lineColor | string | | Color of the line next to the title. Shorthand for colors.line. |
| onCollapsedChange | ((collapsed: boolean) => void) | | Called when the title of a collapsible section is clicked. |
| style | CSSProperties | | Inline styles on the root element. |
| sx | SxProps<Theme> | | Style overrides on the root element. |
| titleColor | string | | Title color. Shorthand for colors.title. |
DetailGrid
| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| children | ReactNode | | DetailFields. |
| className | string | | Class name on the root element. |
| columnGap | string \| number | 32 | Space between columns, in px or any CSS length. |
| columns | 1 \| 2 \| 3 \| 4 | 2 | Most columns side by side. Columns drop one at a time as the grid gets narrower than minColumnWidth per column, down to a single column on small screens. |
| gap | string \| number | | Space between rows and columns, in px or any CSS length. Sets both rowGap and columnGap. |
| id | string | | Id of the root element. |
| minColumnWidth | string \| number | 200 | Narrowest a column may get before the grid drops a column, in px or any CSS length. |
| rowGap | string \| number | 24 | Space between rows, in px or any CSS length. |
| style | CSSProperties | | Inline styles on the root element. |
| sx | SxProps<Theme> | | Style overrides on the root element. |
