Dashboard
A named section, number cards with a trend behind them, and panels in a row.
Sales
Oct 11 to Nov 9
Revenue
Orders
Average order
Refund rate
Oct 11 to Nov 9. Revenue: first $631, last $1,146, low $631, high $1,214.
| date | Revenue |
|---|---|
| Oct 11 | $631 |
| Oct 12 | $972 |
| Oct 13 | $981 |
| Oct 14 | $1,106 |
| Oct 15 | $1,083 |
| Oct 16 | $823 |
| Oct 17 | $702 |
| Oct 18 | $684 |
| Oct 19 | $927 |
| Oct 20 | $1,148 |
| Oct 21 | $1,003 |
| Oct 22 | $974 |
| Oct 23 | $978 |
| Oct 24 | $746 |
| Oct 25 | $738 |
| Oct 26 | $981 |
| Oct 27 | $1,027 |
| Oct 28 | $1,196 |
| Oct 29 | $1,073 |
| Oct 30 | $980 |
| Oct 31 | $781 |
| Nov 1 | $680 |
| Nov 2 | $1,052 |
| Nov 3 | $1,214 |
| Nov 4 | $1,196 |
| Nov 5 | $1,088 |
| Nov 6 | $1,022 |
| Nov 7 | $778 |
| Nov 8 | $786 |
| Nov 9 | $1,146 |
| Product | Revenue |
|---|---|
| House espresso, 1 kg | $9,689 |
| Ethiopia Guji, 250 g | $5,984 |
| Monthly subscription | $5,414 |
| Colombia decaf, 500 g | $4,274 |
| Gooseneck kettle | $3,135 |
Installation
pnpm add @heyramzi/uiUsage
import {
DataTable,
DashboardSection,
PanelGrid,
PeriodFilter,
StatBand,
StatTile,
CHART_HEIGHT,
DAY_WINDOWS,
type DataColumn,
} from "@heyramzi/ui/charts/dashboard";<DashboardSection title="Sales">
<StatBand columns={2}>
<StatTile label="Revenue" value="$48,200" deltaPct={12.4} direction="up-good" lead />
<StatTile label="Orders" value="1,284" deltaPct={-3.1} direction="up-good" />
</StatBand>
<PanelGrid columns={2}>
<section aria-label="Top products">
<DataTable rows={top} {columns} rowKey={(row) => row.id} leadLabel="Product" emptyLabel="No sales">
{#snippet lead(row)}{row.name}{/snippet}
</DataTable>
</section>
</PanelGrid>
</DashboardSection>Keyboard and accessibility
| Key | Does |
|---|---|
| Tab | Moves through the period filter, linked tiles, column sort buttons, row links, and any head, cell or grade that has a hint. |
| Space Enter | On a column's sort button, sorts by it. |
| Esc | On a head, cell or grade with a hint, hides its tooltip. |
- The period filter is a named group of radio buttons, one Tab stop that the arrows move through, or links when href is set.
- The table has real column headers. A sortable head holds a button and reports its sort order.
- A head's hint, a cell's title and a grade's hint show as a tooltip on hover or focus, and the focused one describes itself with it.
- A tile's change reads with its direction, like "up 8%".
- The charts here are named and summarised, hold a hidden table of their values, and the arrow keys step the tooltip.
- With reduced motion on, the numbers show their final value with no count.
API reference
DashboardSection
titlerequiredstringnotestring- One line on the right: a window, a provenance, a count. Never a sentence.
hrefstring- The page that owns this area, when one page does.
openLabelstring- Default
"Open" - The link's wording. Translated at the call site.
actionsSnippet- Controls that scope the whole area, like a period filter. Pinned right, after the note.
childrenrequiredSnippetclassstring
| Prop | Type | Default |
|---|---|---|
title required | string | |
note One line on the right: a window, a provenance, a count. Never a sentence. | string | |
href The page that owns this area, when one page does. | string | |
openLabel The link's wording. Translated at the call site. | string | "Open" |
actions Controls that scope the whole area, like a period filter. Pinned right, after the note. | Snippet | |
children required | Snippet | |
class | string |
PeriodFilter
optionsrequiredreadonly TabDef<T>[]valuerequiredThref(value: T) => string- Give this and the strip is links, so the choice survives reload, back and a shared link. Omit it and the strip is a `<SegmentedFilter>` the caller owns.
onValueChange(value: T) => void- Filter mode only. Ignored when `href` is set.
ariaLabelrequiredstringclassstring
| Prop | Type | Default |
|---|---|---|
options required | readonly TabDef<T>[] | |
value required | T | |
href Give this and the strip is links, so the choice survives reload, back and a shared link. Omit it and the strip is a `<SegmentedFilter>` the caller owns. | (value: T) => string | |
onValueChange Filter mode only. Ignored when `href` is set. | (value: T) => void | |
ariaLabel required | string | |
class | string |
StatBand
childrenrequiredSnippet- `<StatTile>` children. Four to a row on a desk, two on a phone.
columns2 | 3 | 4 | 5 | 6- Default
4 - Cards per row at the widest breakpoint, four unless the set is smaller. Five and six are only for a fixed scorecard. The headline stays one row.
classstring
| Prop | Type | Default |
|---|---|---|
children required `<StatTile>` children. Four to a row on a desk, two on a phone. | Snippet | |
columns Cards per row at the widest breakpoint, four unless the set is smaller. Five and six are only for a fixed scorecard. The headline stays one row. | 2 | 3 | 4 | 5 | 6 | 4 |
class | string |
StatTile
labelrequiredstringvaluerequiredstring- Already formatted. The tile never guesses a currency or a locale.
deltaPctnumber | null- Percent change against the previous period. `null` means nothing to compare yet and draws a dash. Omit it when the figure has no period at all.
direction"up-good" | "down-good" | "neutral"- Default
"neutral" leadboolean- Default
false - The one figure the screen was opened to read. Set it on exactly one tile.
hintstring- A quiet line under the value: what it was measured over, or why it is a dash.
sharenumber- 0 to 1, drawn as a track under the value: share of a total or progress to a target. Omit it for a cash balance.
shareLabelstring- What `share` is measured against, e.g. "of revenue". Only with `share`.
colorstring- Track colour. The first series token unless a tile means something else.
seriesnumber[]- A shape behind the figure, oldest first, bled along the card's bottom. The treatment every tile gives a number with a history. Omit when there is none.
iconPhosphorIcon- Leading mark before the label.
hrefstring- Makes the tile a link, like a balance that opens the bank. It lives here so a linked figure isn't drawn as a second, different card style.
hrefLabelstring- What the link opens, shown on hover. Only with `href`.
target"_self" | "_blank"- Default
"_blank" - `_blank` for a figure that leaves the app (a bank, a provider console), `_self` for one that is another page of this app. Only with `href`.
badgeSnippet- A chip at the end of the label row: the limit the figure is judged against, the state it is in. Wins over `hrefLabel`, which is only a hover hint.
negativeboolean- Default
false - A loss or an overrun: the figure turns the destructive colour.
classstring
| Prop | Type | Default |
|---|---|---|
label required | string | |
value required Already formatted. The tile never guesses a currency or a locale. | string | |
deltaPct Percent change against the previous period. `null` means nothing to compare yet and draws a dash. Omit it when the figure has no period at all. | number | null | |
direction | "up-good" | "down-good" | "neutral" | "neutral" |
lead The one figure the screen was opened to read. Set it on exactly one tile. | boolean | false |
hint A quiet line under the value: what it was measured over, or why it is a dash. | string | |
share 0 to 1, drawn as a track under the value: share of a total or progress to a target. Omit it for a cash balance. | number | |
shareLabel What `share` is measured against, e.g. "of revenue". Only with `share`. | string | |
color Track colour. The first series token unless a tile means something else. | string | |
series A shape behind the figure, oldest first, bled along the card's bottom. The treatment every tile gives a number with a history. Omit when there is none. | number[] | |
icon Leading mark before the label. | PhosphorIcon | |
href Makes the tile a link, like a balance that opens the bank. It lives here so a linked figure isn't drawn as a second, different card style. | string | |
hrefLabel What the link opens, shown on hover. Only with `href`. | string | |
target `_blank` for a figure that leaves the app (a bank, a provider console), `_self` for one that is another page of this app. Only with `href`. | "_self" | "_blank" | "_blank" |
badge A chip at the end of the label row: the limit the figure is judged against, the state it is in. Wins over `hrefLabel`, which is only a hover hint. | Snippet | |
negative A loss or an overrun: the figure turns the destructive colour. | boolean | false |
class | string |
DetailPanel
labelstring- What this panel is, drawn as the app's one panel label. No label, no actions: no header.
labelIconPhosphorIconlabelLeadSnippet- A mark the icon set lacks (a platform logo), drawn ahead of the label at the same size.
sublabelstring- A line under the label, for the scope a number was measured over.
hintstring- A row count, total or freshness stamp. A prop, not an action, because hand-placed hints ended up at three type sizes on one screen.
actionsSnippet- Controls that act on this panel. Pinned right, after the hint.
padboolean- Default
true - Off for a body that supplies its own padding: a table, a media grid, a full-bleed list.
scrollboolean- Default
false - The body scrolls sideways rather than squeezing, for a table wider than the window.
growboolean- Default
false - Takes the height the panels above it left, inside a `fill` stack. One per stack.
childrenrequiredSnippetclassstringbodyClassstring
| Prop | Type | Default |
|---|---|---|
label What this panel is, drawn as the app's one panel label. No label, no actions: no header. | string | |
labelIcon | PhosphorIcon | |
labelLead A mark the icon set lacks (a platform logo), drawn ahead of the label at the same size. | Snippet | |
sublabel A line under the label, for the scope a number was measured over. | string | |
hint A row count, total or freshness stamp. A prop, not an action, because hand-placed hints ended up at three type sizes on one screen. | string | |
actions Controls that act on this panel. Pinned right, after the hint. | Snippet | |
pad Off for a body that supplies its own padding: a table, a media grid, a full-bleed list. | boolean | true |
scroll The body scrolls sideways rather than squeezing, for a table wider than the window. | boolean | false |
grow Takes the height the panels above it left, inside a `fill` stack. One per stack. | boolean | false |
children required | Snippet | |
class | string | |
bodyClass | string |
PanelGrid
childrenrequiredSnippet- `<DetailPanel>` children, or tiles standing beside one.
columns2 | 3 | "main"- Default
2 - Panels per row: two charts, three breakdowns, or `main`, where the first child takes two thirds and the rates beside it one third.
classstring
| Prop | Type | Default |
|---|---|---|
children required `<DetailPanel>` children, or tiles standing beside one. | Snippet | |
columns Panels per row: two charts, three breakdowns, or `main`, where the first child takes two thirds and the rates beside it one third. | 2 | 3 | "main" | 2 |
class | string |
DataTable
rowsrequiredT[]columnsrequiredDataColumn<T>[]rowKeyrequired(row: T) => stringleadLabelrequiredstringleadrequiredSnippet<[T]>emptyLabelrequiredstring- Drawn where a value or rating is null.
leadWidthstring- A Tailwind width class. Omit and the lead takes whatever the figures leave.
minWidthstring- Default
"min-w-[48rem]" - A Tailwind min-width class, past which the panel scrolls sideways.
pageSizenumber- Omit for every row on one page.
sortbindableSortState- Default
null - The ranked column and its direction. Bind it; a column with `sort` sets it.
pagebindablenumber- Default
1 rowHref(row: T) => string- The row opens a page. The lead becomes the link.
onRowClick(row: T) => void- The row opens in place: a panel, a detail view. The lead becomes the button.
loadingboolean- Default
false - Placeholder rows while the data is on its way.
emptySnippet- Drawn in place of the body when there are no rows.
| Prop | Type | Default |
|---|---|---|
rows required | T[] | |
columns required | DataColumn<T>[] | |
rowKey required | (row: T) => string | |
leadLabel required | string | |
lead required | Snippet<[T]> | |
emptyLabel required Drawn where a value or rating is null. | string | |
leadWidth A Tailwind width class. Omit and the lead takes whatever the figures leave. | string | |
minWidth A Tailwind min-width class, past which the panel scrolls sideways. | string | "min-w-[48rem]" |
pageSize Omit for every row on one page. | number | |
sort bindable The ranked column and its direction. Bind it; a column with `sort` sets it. | SortState | null |
page bindable | number | 1 |
rowHref The row opens a page. The lead becomes the link. | (row: T) => string | |
onRowClick The row opens in place: a panel, a detail view. The lead becomes the button. | (row: T) => void | |
loading Placeholder rows while the data is on its way. | boolean | false |
empty Drawn in place of the body when there are no rows. | Snippet |
RatingChip
graderequiredstringhintstring- What the letter hides: the score and what it was charged for.
classstring
| Prop | Type | Default |
|---|---|---|
grade required | string | |
hint What the letter hides: the score and what it was charged for. | string | |
class | string |