Skip to content
h v3.13.3
Search the docs
Find a component, section or page.

Dashboard

A named section, number cards with a trend behind them, and panels in a row.

Sales

Oct 11 to Nov 9

Revenue

$28,496 up 5%

Orders

715 up 6%

Average order

$39.85 down 1%

Refund rate

1.3% down 15%
Revenue per day
$950
Daily average

Oct 11 to Nov 9. Revenue: first $631, last $1,146, low $631, high $1,214.

Area chart
dateRevenue
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
Top products
ProductRevenue
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
Orders by weekday

Mon to Sun. Orders: first 127, last 88, low 76, high 127.

Orders by weekday
labelOrders
Mon127
Tue109
Wed113
Thu106
Fri96
Sat76
Sun88

Installation

pnpm add @heyramzi/ui

Usage

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

title required string
note string
One line on the right: a window, a provenance, a count. Never a sentence.
href string
The page that owns this area, when one page does.
openLabel string
Default "Open"
The link's wording. Translated at the call site.
actions Snippet
Controls that scope the whole area, like a period filter. Pinned right, after the note.
children required Snippet
class string
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

options required readonly TabDef<T>[]
value required T
href (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.
ariaLabel required string
class string
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

children required Snippet
`<StatTile>` children. Four to a row on a desk, two on a phone.
columns 2 | 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.
class string
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

label required string
value required string
Already formatted. The tile never guesses a currency or a locale.
deltaPct number | 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"
lead boolean
Default false
The one figure the screen was opened to read. Set it on exactly one tile.
hint string
A quiet line under the value: what it was measured over, or why it is a dash.
share number
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.
shareLabel string
What `share` is measured against, e.g. "of revenue". Only with `share`.
color string
Track colour. The first series token unless a tile means something else.
series number[]
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.
icon PhosphorIcon
Leading mark before the label.
href string
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.
hrefLabel string
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`.
badge Snippet
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.
negative boolean
Default false
A loss or an overrun: the figure turns the destructive colour.
class string
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

label string
What this panel is, drawn as the app's one panel label. No label, no actions: no header.
labelIcon PhosphorIcon
labelLead Snippet
A mark the icon set lacks (a platform logo), drawn ahead of the label at the same size.
sublabel string
A line under the label, for the scope a number was measured over.
hint string
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.
actions Snippet
Controls that act on this panel. Pinned right, after the hint.
pad boolean
Default true
Off for a body that supplies its own padding: a table, a media grid, a full-bleed list.
scroll boolean
Default false
The body scrolls sideways rather than squeezing, for a table wider than the window.
grow boolean
Default false
Takes the height the panels above it left, inside a `fill` stack. One per stack.
children required Snippet
class string
bodyClass string
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

children required Snippet
`<DetailPanel>` children, or tiles standing beside one.
columns 2 | 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.
class string
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

rows required T[]
columns required DataColumn<T>[]
rowKey required (row: T) => string
leadLabel required string
lead required Snippet<[T]>
emptyLabel required string
Drawn where a value or rating is null.
leadWidth string
A Tailwind width class. Omit and the lead takes whatever the figures leave.
minWidth string
Default "min-w-[48rem]"
A Tailwind min-width class, past which the panel scrolls sideways.
pageSize number
Omit for every row on one page.
sort bindable SortState
Default null
The ranked column and its direction. Bind it; a column with `sort` sets it.
page bindable number
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.
loading boolean
Default false
Placeholder rows while the data is on its way.
empty Snippet
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

grade required string
hint string
What the letter hides: the score and what it was charged for.
class string
Prop Type Default
grade required string
hint

What the letter hides: the score and what it was charged for.

string
class string