Reeve Docs

Docs / Development

Design tokens

The colour roles, spacing, radii, elevation and widths the web application is built from. A new screen names a role from this page; it does not pick a hex value, a pixel size or a corner radius of its own, and it does not invent a hero box or a chip when one of the roles below already is one.

Where they live: colours in lib/brandTokens.ts (both schemes) assembled into the palette by lib/theme.ts; everything else in lib/designTokens.ts, exposed as theme.reeve. Both are typed through module augmentation in lib/theme.ts, so theme.reeve.* and palette.surface.inset type-check wherever a theme is in scope.

Read tokens through the theme, in sx. Under CSS variables theme.palette.* is frozen to the light scheme; read theme.vars.palette.* or an sx palette path ('text.secondary', 'surface.inset'). Use a callback — sx={(theme) => ({ borderRadius: theme.reeve.radius.round })} — for anything from theme.reeve. A test that renders a themed component must render under the app theme (render, or renderWithTheme where the test mounts its own router, both in test/render.tsx): MUI's default theme has no reeve.

Colour roles

Forest green, cream and brass are the brand; every value has a light and a dark entry in brandTokens.ts, so a role never needs a scheme check at the call site.

Role Token Use
Page background.default The cream behind everything
Card background.paper Cards, tiles, summary cards, drawers
Inset surface.inset A panel set into a card: a reading, a log block, a diagnostics strip. Use it instead of the cream grey.50 and grey.100
Line divider Borders and rules. Equal to grey.200 and grey.300 in both schemes
Ink text.primary, text.secondary, text.disabled Body, supporting and inactive text
Brand primary, secondary (brass) Actions and emphasis; a contained primary button is forest in light, brass in dark
Tone success, warning, error, info The four tones. Each has main (fill), contrastText (ink on the fill), hover, and the 50 and 200 shades
Tone ink successText, warningText, errorText; info.main A tone as text. The fills miss 4.5:1 on a card, so text takes these
Tone tint toneTint(theme, tone, role) in features/ui/tone.ts A tone over any surface at a named strength, built from the tone's channel so it follows the scheme
Status StatusTone (neutral, success, warning, danger, info) A health or state value. The dot, the pill and the chip colour all come from toneToChipColor; a raw colour string is never used for a status

Tint strengths (theme.reeve.tint): chip 0.20 for an icon chip, tile 0.28 for a whole Start tile, panel 0.10 for a status panel and panelBorder 0.35 for its border. A tile reads its tone from the device (resolveTileTone): amber for a light that is on, green for power, terracotta for heat, slate for cool; anything else stays neutral.

Colour literals are a lint error on the Basic surfaces listed in eslint.config.js, and theme.palette is an error everywhere outside the theme: the two ways a colour stops following the scheme.

Spacing

The MUI 8 px scale (theme.spacing); sx numbers are units, so p: 2 is 16 px.

Role Units Use
Page padding theme.reeve.space.page: 2 on a phone, 3 from 600 px A screen's outer padding
Section gap 3 Between cards and sections
Card padding 2 to 3 Inside a card or tile
Form stack 2 Between form fields
Button stack 1 Between buttons
Grid gap 1.5 Between tiles and summary cards

Radii

theme.reeve.radius.* are CSS strings. The sx borderRadius multiplies a bare number by the theme shape (12 px), so borderRadius: 3 is 36 px; pass the token, not a number. radiusPx carries the same values as numbers for a theme styleOverrides.

Token px Use
chip 6 Chips
control 8 Buttons, list entries
surface 12 The theme shape: papers, cards, inputs, tiles
panel 24 An inset panel inside a control
round 36 Quick-scene buttons, a summary card's icon square
card 48 The Start summary card

A circle is '50%'. A numeric borderRadius: 2 is the panel size by another spelling, so use the token. 1 (12 px) is surface; 1.5 (18 px) has no token, so leave it rather than rounding it to panel. A numeric borderRadius is a lint error on the Basic surfaces listed in eslint.config.js.

Elevation

theme.reeve.elevation indexes theme.shadows. resting (1) is a card or tile on the page. A Card ignores that index and takes the theme's own shadow, which differs per scheme; Paper elevation={1} and boxShadow: 1 (the Start summary card) draw theme.shadows[1], which is the same in both schemes and is not the Card shadow. raised (2) is something lifted off the page, such as a control's floating dial button. Nothing else on a redesigned screen uses a higher level; a shadow never carries meaning by itself.

Widths and sizes

Token px Use
width.content 1440 The column cap of a list or form page and of the Start summary strip (contentWidthSx)
width.start 2200 Start fills the window up to here; past it a row of tiles is too far to scan
width.drawer 480 The Basic device drawer above a phone; a phone gets the full width
size.iconChip 40 A tile's icon chip and a summary card's icon square; a tile's control is no taller, so a tile has one height
size.statusDot 10 The status dot

Dark scheme

Colours switch through the palette; tints through the tone's channel; radii, spacing and widths do not depend on the scheme. The one token whose look differs is the shadow of a Card, which the theme overrides per scheme.

Dark values live beside the light ones in brandTokens.ts: page #0F1714, card #172420, inset #1F2E28, line #2C3D36, ink #EDEAE1 with #9DB0A6 for supporting text, and the tone fills and text twins as listed there. A contained primary button is brass in dark, and action.active (default icons) is the body ink, not white. Four rules follow from the scheme:

  • A tone tint is the tone's fill at a strength over the card, so a tinted surface is lighter than the card in dark and the plain tone ink (successText, errorText, info.main) loses contrast on it. Text on a Start tile therefore takes toneInkOnTile: the tone ink mixed TILE_INK_TEXT_SHARE (30%) toward text.primary. The mix is computed per scheme, so one rule serves both.
  • A standard Alert in dark takes the tone's 50 shade as its fill (palette.Alert.*StandardBg, pinned in theme.ts). MUI's own derivation is a near-black box darker than the page. The 50 shade is as dark as a card, so alertRing rings the alert in the tone at tint.panelBorder.
  • Ink on a tone fill is the fill's contrastText, never white. In dark every main fill is a light pastel, so white on it is about 2.3:1. ESLint rejects a white color literal (white, common.white, #fff, rgb(255,255,255), a static template, a palette.common.white access) in src; ink over a picture and a user-picked colour carry an eslint-disable that says so. A switch knob on a tone track takes toneKnob(tone), the tone's contrastText.
  • A code or diagnostics block uses surface.inset with text.primary in dark. grey.900 with grey.100 is a dark block in light only, because grey.100 is itself a dark inset in dark.

A lamp's bulb disc is the device's own colour, not a role: it stays an amber literal in both schemes, and in dark its glyph takes warning.contrastText. The disc's opacity follows the brightness above a 0.4 floor (lampDiscAlpha), so at any brightness the glyph is at least 3:1 on it; controls/lampDisc.test.ts proves it.

The contrast guard

lib/theme.guards.test.ts computes every pair from the theme's real values, in both schemes: Typography inks against the opaque surfaces and the standard Alert fills (read from palette.Alert); Alert text against its fill; and tone tints composited over the card (tint.tile, tint.chip, tint.panel). It calls toneInkOnTile, toneTint and alertRing and resolves their theme variables against the scheme's palette, so it checks the code that ships, not a copy of its formula. On a tile it asserts the tile ink and the name at 4.5:1; on a chip the glyph at 3:1 (non-text); on a panel the body inks and the tone ink at 4.5:1. Change a tint strength or a tone fill and the guard says whether the inks still read.