---
title: UI kit - Data display
summary: The @spacemix/ui read-only views of data - badges, tags, status dots, avatars, cards, stats, description lists, tables, lists, trees, timelines, code, progress and meters, skeletons and spinners, highlighted text, formatted times, sizes and numbers, and kanban boards - with their props.
audience: both
stability: experimental
since: protocol 1
---

# Data display

Read-only views of data, from a single badge to a sortable table. Source: `packages/ui/src/data.tsx` (and `Spinner` in `components.tsx`). [`Kbd`](../ui.md#kbd) and [`Markdown`](../ui.md#markdown) are on the kit's main page.

Every component takes the native props of its root element, `className` joined last and `ref`. The [conventions](../ui.md#conventions) apply: `tone` is a `Tone`, `size` a `Size`.

**Stability:** experimental, every export on this page: new in this release, and names and props may still be adjusted before they are promised.

## `Badge`

A short label for a status, a count or a category. `lucide-react` also has a `Badge` icon; import it as `BadgeIcon`.

| Prop | Type | Default | What it does |
|---|---|---|---|
| `tone` | `Tone` | `"neutral"` | What the badge means. |
| `variant` | `"soft" \| "solid" \| "outline"` | `"soft"` | A tinted fill (the status color as text on its `-soft` tint), a solid fill, or a border only. A solid fill puts `surface` on the status color, which reads in both themes. |
| `size` | `Size` | `"md"` | The height and text size. |
| `dot` | `boolean` | none | A small dot in the tone's color before the label. |

```tsx
<Badge tone="success" dot>Live</Badge>
```

`BadgeProps` is the props type.

## `Tag`

A chip for a value someone picked (a filter, a label, a recipient), removable when `onRemove` is set. `lucide-react` also has a `Tag` icon; import it as `TagIcon`.

| Prop | Type | Default | What it does |
|---|---|---|---|
| `tone` | `Tone` | `"neutral"` | `"neutral"` is a bordered surface chip. |
| `size` | `Size` | `"md"` | The height and text size. |
| `icon` | `ReactNode` | none | An icon (`size-3.5`) or avatar before the label. |
| `onRemove` | `() => void` | none | Shows a remove button; also called on Backspace or Delete while the tag has focus. |
| `removeLabel` | `string` | `"Remove <label>"` | The remove button's accessible name. |
| `disabled` | `boolean` | none | Dims it and turns the remove button off. |

`TagProps` is the props type.

## `StatusDot`

A small colored dot for a state (online, running, failed), next to a label or on its own.

| Prop | Type | Default | What it does |
|---|---|---|---|
| `tone` | `Tone` | `"neutral"` | The color. |
| `size` | `Size` | `"md"` (8 px) | The dot's size. |
| `pulse` | `boolean` | none | A soft ring that pings outwards, for live or running states. Still under reduced motion. |
| `label` | `string` | none | Read out by screen readers; without it the dot is decorative. When there is room, put visible text next to it instead. |

`StatusDotProps` is the props type.

## `Avatar`, `AvatarStatus`

```ts
type AvatarStatus = "online" | "away" | "busy" | "offline";
```

A picture of a person or thing, falling back to initials on a tint picked from the name (so a person keeps one color), with an optional presence dot.

| Prop | Type | Default | What it does |
|---|---|---|---|
| `src` | `string` | none | The image. When it is missing or fails to load, the initials of `name` show. |
| `name` | `string` | `""` | The initials, the tint and the accessible name. |
| `alt` | `string` | none | The accessible name when it should differ from `name`. |
| `size` | `Size` | `"md"` | `"sm"` 24 px, `"md"` 32 px, `"lg"` 40 px. |
| `shape` | `"circle" \| "square"` | `"circle"` | Round for people, a rounded square for workspaces, bots and apps. |
| `status` | `AvatarStatus` | none | A presence dot on the corner; its state is added to the accessible name. |
| `icon` | `ReactNode` | none | Shown instead of initials when there is no image and no name. |

`AvatarProps` is the props type.

## `AvatarGroup`

Overlapping avatars for the people on something, folding the rest into a "+N" count.

| Prop | Type | Default | What it does |
|---|---|---|---|
| `children` | `ReactNode` | required | `Avatar` elements; their `size` is set from the group's. |
| `max` | `number` | `4` | How many show before the rest fold into "+N". |
| `total` | `number` | none | How many there are in all, when only some are passed. |
| `size` | `Size` | `"md"` | The avatars' size. |

`AvatarGroupProps` is the props type.

## `Card`, `CardHeader`, `CardBody`, `CardFooter`

A panel that groups one thing's content, with `CardHeader`, `CardBody` and `CardFooter` for its parts; interactive and selectable when it is a choice.

| `Card` prop | Type | Default | What it does |
|---|---|---|---|
| `variant` | `"outline" \| "elevated" \| "filled"` | `"outline"` | A bordered surface, a raised panel with a shadow, or a quiet filled panel. |
| `interactive` | `boolean` | none | The whole card is one button (`role="button"`, Enter and Space call `onClick`), with hover and press states. Don't put other buttons inside one. |
| `selected` | `boolean` | none | Marks the card as picked with an accent border; on an interactive card it also sets `aria-pressed`. |
| `disabled` | `boolean` | none | Dims an interactive card and stops `onClick`. |

| `CardHeader` prop | Type | Default | What it does |
|---|---|---|---|
| `title` | `ReactNode` | none | The card's heading. |
| `description` | `ReactNode` | none | A line under the title. |
| `icon` | `ReactNode` | none | An icon or avatar before the title. |
| `actions` | `ReactNode` | none | Buttons or a menu on the right. |

`CardHeader` also takes any children instead. `CardBody` is the padded main content; `CardFooter` a bordered row for the card's actions (right-aligned) or a note. Both take the `<div>` props.

```tsx
<Card>
  <CardHeader title="Backups" description="Every night at 02:00" actions={<Switch aria-label="Backups" checked={on} onChange={setOn} />} />
  <CardBody>Last run 3 hours ago.</CardBody>
  <CardFooter><Button size="sm">Run now</Button></CardFooter>
</Card>
```

`CardProps` and `CardHeaderProps` are the props types. For a bare surface, use [`Panel`](layout.md#panel).

## `Stat`

One headline number with its label, its change (up or down, colored by which way is good) and room for a sparkline.

| Prop | Type | Default | What it does |
|---|---|---|---|
| `label` | `ReactNode` | required | What is measured, above the value. |
| `value` | `ReactNode` | required | The figure; format it first (`formatNumber`, `formatFileSize`). |
| `delta` | `number` | none | The change. The sign sets the arrow and the color. |
| `deltaKind` | `"percent" \| "fraction" \| "absolute"` | `"percent"` | What `delta` holds: `12.5` → "+12.5%" (`"percent"`), `0.125` → "+12.5%" (`"fraction"`), `340` → "+340" in the value's own unit (`"absolute"`). Ignored when `deltaFormat` is set. |
| `deltaFormat` | `(delta: number) => string` | by `deltaKind` | Formats `delta`; wins over `deltaKind`. |
| `deltaLabel` | `ReactNode` | none | Next to the delta: "vs last week". |
| `positive` | `"up" \| "down"` | `"up"` | Which way is good: `"up"` makes a rise green, `"down"` a fall. |
| `icon` | `ReactNode` | none | An icon next to the label. |
| `chart` | `ReactNode` | none | A `Sparkline` or small chart below the value. |
| `size` | `Size` | `"md"` | The value's size. |

`StatProps` is the props type.

## `DescriptionList`, `DescriptionItem`

```ts
interface DescriptionItem { label: ReactNode; value: ReactNode; id?: string }  // id: a React key when labels aren't unique strings
```

Key-value pairs (the details of a record, metadata, settings at a glance) as a `<dl>`, side by side or stacked in a grid. Long values wrap.

| Prop | Type | Default | What it does |
|---|---|---|---|
| `items` | `DescriptionItem[]` | required | The rows. |
| `orientation` | `"horizontal" \| "vertical"` | `"horizontal"` | Label beside value (settings-like details), or label above value in a grid (summary facts). |
| `columns` | `1 \| 2 \| 3 \| 4` | `2` | Columns of the vertical grid; phones show at most two. |
| `divided` | `boolean` | `true` | Rules between horizontal rows. |
| `dense` | `boolean` | none | Tighter rows. |

`DescriptionListProps` is the props type.

## `Table`, `TableColumn`, `TableSort`, `SortDirection`

```ts
type SortDirection = "ascending" | "descending";   // the values aria-sort takes
interface TableSort { key: string; direction: SortDirection }
```

A table from column definitions: sortable headers (`aria-sort`), row selection with checkboxes, clickable rows, a sticky header, dense rows, numeric columns, and loading and empty rows. `lucide-react` also has a `Table` icon; import it as `TableIcon`.

| `TableColumn<T>` field | Type | Default | What it does |
|---|---|---|---|
| `key` | `string` | required | Unique; also the field read from a row when there is no `cell`. |
| `header` | `ReactNode` | required | The header's content. |
| `cell` | `(row: T, index: number) => ReactNode` | `String(row[key])` | The cell's content. |
| `sortable` | `boolean` | none | Clicking the header sorts by this column: ascending, descending, then unsorted. |
| `sortValue` | `(row: T) => string \| number \| Date \| boolean \| null \| undefined` | `row[key]` | What to sort by; numbers and dates compare as such, strings in natural order. |
| `align` | `"start" \| "center" \| "end"` | `"start"`, `"end"` when `numeric` | Cell alignment. |
| `numeric` | `boolean` | none | Right-aligned with tabular figures, for amounts, counts and sizes. |
| `width` | `string \| number` | none | A CSS width (`"8rem"`, `"30%"`, `120`). |
| `truncate` | `boolean` | none | Keeps cells on one line, ending in "…". |
| `hideOnMobile` | `boolean` | none | Hides the column below `md`, so phones keep the columns that matter. |

| `Table<T>` prop | Type | Default | What it does |
|---|---|---|---|
| `columns` | `TableColumn<T>[]` | required | The columns. |
| `rows` | `T[]` | required | The rows. |
| `rowKey` | `(row: T, index: number) => string` | `row.id`, else the index | A stable key per row, used for selection. |
| `sort` | `TableSort \| null` | none | The sorted column (controlled); `null` for none. |
| `defaultSort` | `TableSort \| null` | `null` | The starting sort when uncontrolled. |
| `onSortChange` | `(sort: TableSort \| null) => void` | none | Called when a header changes the sort. |
| `manualSort` | `boolean` | none | Leaves the rows in the order given (you sort, for example on the server); headers still show and change the sort. |
| `selectable` | `boolean` | none | A checkbox column, with select-all in the header. |
| `selected` | `string[]` | none | Selected row keys (controlled). |
| `defaultSelected` | `string[]` | `[]` | Selected row keys to start with. |
| `onSelectedChange` | `(keys: string[]) => void` | none | Called with the selected keys. |
| `rowLabel` | `(row: T, index: number) => string` | the row's position | Names a row for its checkbox ("Select <name>"). |
| `onRowClick` | `(row: T, index: number) => void` | none | Rows are clickable, and Enter opens the focused row. Clicks on buttons, links and inputs inside a row don't count. |
| `dense` | `boolean` | none | 32 px rows instead of 40 px. |
| `stickyHeader` | `boolean` | none | The header stays at the top while the table scrolls; give the table a height (`max-h-96`) through `className`. |
| `loading` | `boolean` | none | Placeholder rows instead of `rows`, sized like real ones. |
| `loadingRows` | `number` | `3` | How many placeholder rows. |
| `empty` | `ReactNode` | `"Nothing here yet."` | Shown in one full-width row when there are no rows. |
| `caption` | `string` | none | Names the table for screen readers (a visually hidden caption). |
| `bordered` | `boolean` | `true` | A border and rounded corners around the table. |

```tsx
const columns: TableColumn<Invoice>[] = [
  { key: "number", header: "Invoice", sortable: true },
  { key: "amount", header: "Amount", numeric: true, sortable: true, cell: (r) => formatNumber(r.amount, { style: "currency", currency: "EUR" }) },
];
<Table columns={columns} rows={invoices} onRowClick={(r) => host.view.navigate(`invoices/${r.id}`)} caption="Invoices" />
```

`TableProps` is the props type.

## `List`, `ListItem`

`List` is a vertical list of `ListItem` rows (a `<ul>`), divided and optionally bordered as a panel. `lucide-react` also has a `List` icon; import it as `ListIcon`.

| `List` prop | Type | Default | What it does |
|---|---|---|---|
| `divided` | `boolean` | `true` | Rules between items. |
| `bordered` | `boolean` | none | A border and rounded corners, as a panel. |
| `dense` | `boolean` | `false` | 36 px rows instead of 48 px. |

| `ListItem` prop | Type | Default | What it does |
|---|---|---|---|
| `title` | `ReactNode` | required | The row's main text; truncates. |
| `description` | `ReactNode` | none | A second line; truncates. |
| `leading` | `ReactNode` | none | An icon (`size-4`) or `Avatar` before the text. |
| `meta` | `ReactNode` | none | Quiet text on the right, such as a time or a count. |
| `trailing` | `ReactNode` | none | Buttons or a menu on the right; they stay clickable on their own. |
| `onClick` | `MouseEventHandler<HTMLButtonElement>` | none | Makes the row a button; gets the click event. |
| `href` | `string` | none | Makes the row a link. |
| `selected` | `boolean` | none | Marks the row as the current one, with an accent tint (`aria-current`). |
| `disabled` | `boolean` | none | Dims it and turns it off. |
| `handle` | `boolean` | none | A grip before the content, for rows that can be dragged; the dragging is yours to wire. |

`ListProps` and `ListItemProps` are the props types.

## `Tree`, `TreeNode`

```ts
interface TreeNode {
  id: string;            // unique across the whole tree
  label: ReactNode;
  textValue?: string;    // what typeahead matches, when label isn't a string
  icon?: ReactNode;      // size-4, before the label
  meta?: ReactNode;      // quiet text on the right
  children?: TreeNode[]; // a node with children (even []) can expand
  disabled?: boolean;    // focusable but not selectable
}
```

A hierarchy (folders, pages, sections) that expands and collapses, with the WAI-ARIA tree keyboard: Up and Down move, Right expands or moves into a node, Left collapses or moves to the parent, Home and End go to the ends, `*` expands the siblings, Enter or Space activates, and typing jumps to a node.

| Prop | Type | Default | What it does |
|---|---|---|---|
| `nodes` | `TreeNode[]` | required | The top-level nodes. |
| `expanded` | `string[]` | none | Expanded node ids (controlled). |
| `defaultExpanded` | `string[]` | `[]` | Expanded node ids to start with. |
| `onExpandedChange` | `(ids: string[]) => void` | none | Called with the expanded ids. |
| `selected` | `string \| null` | none | The selected node id (controlled); `null` for none. |
| `defaultSelected` | `string \| null` | `null` | The selected node id to start with. |
| `onSelectedChange` | `(id: string \| null) => void` | none | Called with the selected id. |
| `onActivate` | `(node: TreeNode) => void` | none | Called on click, Enter or Space on a node that isn't disabled, after it is selected: open the file, go to the page. |
| `dense` | `boolean` | none | 28 px rows instead of 32 px. |

`TreeProps` is the props type.

## `Timeline`, `TimelineItem`

```ts
interface TimelineItem {
  id: string;
  title: ReactNode;         // what happened: "Ada merged #42"
  description?: ReactNode;
  time?: ReactNode;         // a RelativeTime fits
  icon?: ReactNode;         // size-3.5, in the marker; without one the marker is a dot
  tone?: Tone;              // the marker's color, default "neutral"
  content?: ReactNode;      // anything below: a quoted comment, attachments
}
```

An activity feed (an `<ol>`): events in order with a marker and a connecting line, a title, a time and optional content. Props: `items` (`TimelineItem[]`, required) and `dense` (less space between events). `TimelineProps` is the props type. `lucide-react` also has a `Timeline` icon; import it as `TimelineIcon`.

## `CodeBlock`, `InlineCode`

`CodeBlock` is a block of code or command output in the mono font, with an optional title bar, line numbers, highlighted lines and a copy button. There is no syntax coloring.

| Prop | Type | Default | What it does |
|---|---|---|---|
| `code` | `string` | required | The code, as plain text. |
| `language` | `string` | none | Shown in the header bar ("ts", "json", "bash"). |
| `title` | `ReactNode` | none | A file name or caption in the header bar. |
| `lineNumbers` | `boolean` | none | Line numbers in a gutter; they aren't copied. |
| `highlightLines` | `number[]` | none | 1-based lines to tint, for pointing at a change. |
| `copyable` | `boolean` | `true` | A copy button. |
| `wrap` | `boolean` | none | Wraps long lines instead of scrolling sideways. |
| `maxHeight` | `number \| string` | none | The tallest the code area gets (a number is px); taller code scrolls inside it. |
| `collapsedLines` | `number` | none | Starts folded to this many lines, with a button under the code to show all of it and fold it again. Only when the code is longer. |

`InlineCode` is code inside running text (a name, a path, a value), a `<code>` that takes the native props. `CodeBlockProps` is the props type.

## `Progress`, `ProgressCircle`

A linear progress bar and a circular ring, each determinate or indeterminate.

| `Progress` prop | Type | Default | What it does |
|---|---|---|---|
| `value` | `number \| null` | none | How far along; leave out (or `null`) for an indeterminate bar that moves while the length is unknown. |
| `max` | `number` | `100` | The value at the end. |
| `tone` | `Tone` | `"accent"` | The bar's color. |
| `size` | `Size` | `"md"` | The bar's thickness. |
| `label` | `ReactNode` | none | A label above the bar; also its accessible name. Without it pass `aria-label`. |
| `showValue` | `boolean` | none | The percentage (or `valueLabel`) on the right of the label row. |
| `valueLabel` | `(value: number, max: number) => string` | none | Formats the shown and spoken value: `(v, max) => "3 of 8 files"`. |

`ProgressCircle` takes `value`, `max`, `tone` and `valueLabel` as `Progress` does, and:

| `ProgressCircle` prop | Type | Default | What it does |
|---|---|---|---|
| `size` | `Size` | `"md"` | 20, 36 or 56 px. |
| `showValue` | `boolean` | none | The percentage (or `valueLabel`) in the middle; only at `"md"` and `"lg"`. |
| `label` | `string` | `"Progress"` | The accessible name. |

`ProgressProps` and `ProgressCircleProps` are the props types.

## `Meter`

A gauge of a value within a known range (storage used, a quota, a score), turning warning or danger past the thresholds the way `<meter>` does.

| Prop | Type | Default | What it does |
|---|---|---|---|
| `value` | `number` | required | The measured value. |
| `min` | `number` | `0` | The range's start. |
| `max` | `number` | `100` | The range's end. |
| `low` | `number` | none | Below this the value is low. |
| `high` | `number` | none | Above this the value is high. |
| `optimum` | `number` | the middle of the range | The best value: below `low` when less is better (errors), above `high` when more is (battery). With `low` and `high` it picks the tone. |
| `tone` | `Tone` | from `low`, `high`, `optimum` | Fixes the tone. |
| `size` | `Size` | `"md"` | The bar's thickness. |
| `label` | `ReactNode` | none | A label above the bar; also its accessible name. |
| `showValue` | `boolean` | none | The value on the right of the label row. |
| `valueLabel` | `(value: number, max: number) => string` | none | Formats the shown and spoken value: `(v, max) => "42 of 50 GB"`. |

`MeterProps` is the props type. For a dial, see [`Gauge`](charts.md#gauge-gaugethreshold).

## `Skeleton`

A pulsing placeholder in the shape of the content to come, so the layout doesn't shift when it arrives; hidden from screen readers.

| Prop | Type | Default | What it does |
|---|---|---|---|
| `variant` | `"text" \| "circle" \| "rect"` | `"text"` | Lines of text, a circle (an avatar) or a box (an image, a card). |
| `lines` | `number` | `1` | Text lines; the last of several is shorter. |
| `width` | `string \| number` | full width (text, rect), 32 px (circle) | A CSS width. |
| `height` | `string \| number` | one line, 32 px (circle), 96 px (rect) | A CSS height. |

`SkeletonProps` is the props type.

## `Spinner`

A spinning loader for a wait of unknown length, in a button, a row or a panel (a `role="status"` span); it stands still under reduced motion. For a whole view, use [`LoadingState`](feedback.md#loadingstate).

| Prop | Type | Default | What it does |
|---|---|---|---|
| `size` | `Size` | `"md"` | 14, 16 or 24 px. |
| `tone` | `Tone` | the surrounding text color | The color. |
| `label` | `string` | `"Loading"` | Read out by screen readers. |

`SpinnerProps` is the props type.

## `Highlight`

Text with the parts that match a search marked (`<mark>`), for results and filtered lists.

| Prop | Type | Default | What it does |
|---|---|---|---|
| `text` | `string` | required | The text to show. |
| `query` | `string \| string[]` | required | What to mark: a search query or several words. Empty marks nothing. |
| `caseSensitive` | `boolean` | `false` | Matches case. |

`HighlightProps` is the props type.

## `RelativeTime`, `formatRelativeTime`

```ts
function formatRelativeTime(date: Date | string | number, options?: { now?: Date | number; locale?: string; style?: "long" | "short" | "narrow" }): string;
```

`formatRelativeTime` formats how long ago (or how far ahead) a date is: "just now", "5 minutes ago", "yesterday", "in 3 days". `RelativeTime` is a `<time>` that shows it, keeps itself current and shows the full date and time on hover.

| `RelativeTime` prop | Type | Default | What it does |
|---|---|---|---|
| `date` | `Date \| string \| number` | required | The moment: a `Date`, an ISO string or epoch milliseconds. |
| `live` | `boolean` | `true` | Keeps the text current while it is on screen (every 30 seconds within a day). |
| `locale` | `string` | the browser's | The language. |
| `format` | `"long" \| "short" \| "narrow"` | `"long"` | `"short"` gives "5 min. ago". |

`RelativeTimeProps` is the props type.

## `FileSize`, `formatFileSize`

```ts
function formatFileSize(bytes: number, options?: { binary?: boolean; decimals?: number; locale?: string }): string;
```

`formatFileSize` formats a byte count for people: "0 B", "512 B", "1.4 MB" (1000-based), or "1.3 MiB" with `binary`. `FileSize` shows it with the exact number of bytes on hover; it takes `bytes` (required), `binary` (default `false`), `decimals` (default 1) and `locale`. `FileSizeProps` is the props type.

## `NumberFormat`, `formatNumber`

```ts
function formatNumber(value: number, options?: Intl.NumberFormatOptions & { compact?: boolean; locale?: string }): string;
```

`formatNumber` formats a number with `Intl.NumberFormat`; `compact` gives "1.2K", "3.4M". `NumberFormat` shows a number for the reader's locale in tabular figures, compact with the full value on hover. It takes `value` (required), `compact`, `options` (any `Intl.NumberFormatOptions`: `{ style: "currency", currency: "EUR" }`, `{ style: "percent" }`) and `locale`. `NumberFormatProps` is the props type.

## `Board`, `BoardColumn`, `BoardCard`

A kanban board: `Board` is a row of `BoardColumn`s that scrolls sideways, one column per screen on phones. Columns snap with 16 px of scroll padding (the page padding on phones); with other side padding pass a matching `scroll-px-*` in `className`. The dragging between columns is yours to wire.

| `BoardColumn` prop | Type | Default | What it does |
|---|---|---|---|
| `title` | `ReactNode` | required | The column's name: a status or a stage. |
| `count` | `number` | none | A count next to the title. |
| `tone` | `Tone` | none | A status dot before the title. |
| `actions` | `ReactNode` | none | Buttons or a menu on the right of the header. |
| `footer` | `ReactNode` | none | Below the cards: an "Add card" button. |
| `empty` | `ReactNode` | `"No cards"` | Shown when the column has no cards. |

| `BoardCard` prop | Type | Default | What it does |
|---|---|---|---|
| `title` | `ReactNode` | required | The card's title. |
| `description` | `ReactNode` | none | A line or two under the title; clamps at two lines. |
| `labels` | `ReactNode` | none | Badges or tags above the title. |
| `meta` | `ReactNode` | none | A row at the bottom: avatars, a due date, a count of comments. |
| `actions` | `ReactNode` | none | A menu or button in the top-right corner; stays clickable on its own. |
| `onClick` | `MouseEventHandler<HTMLButtonElement>` | none | The card opens something; gets the click event. |
| `selected` | `boolean` | none | Marks the card as the open one. |

`BoardProps`, `BoardColumnProps` and `BoardCardProps` are the props types.
