Skip to content

0029 spotstrap recipes

github-actions[bot] edited this page Nov 19, 2026 · 1 revision

The app's own components take their classes from Spotstrap's recipes

Status: accepted · Implementation: done · Date: 2026-11-19 · Supersedes: 0027

From the move LibreLifts makes at the same time. Supersedes only the part of 0027 about where a component's classes come from. The components are still the app's own, written here, and React Native Reusables is still added only for behaviour that is hard to get right. Built 2026-11-19 with Spotstrap 0.1.3: Button, TextField, NumberField, the done tick in SetRow and the action in Problem. TextField has no visible label, so it uses input() alone. The tick is the recipe's 20-point box, centred in a 44-point cell so that it lines up with the fields. Checked in the iOS Simulator, light and dark: a set is logged and ticked, and the tick answers a tap 20 points from its centre.

Context

0027 had the app write its first components by hand, each with a map from a variant name to a full class string. 0028 then took the theme from Spotstrap. Spotstrap also ships recipes for React Native (@kodentuzo/spotstrap/recipes): plain functions that take a component's variant and state and return its classes, { className, textClassName?, hitSlop? }, as full Uniwind class strings. They are built from the same sizes and type scale as the website's components: 44-point targets, 36-point compact controls whose hit area is still 44, and Apple's text styles.

React Native has no :hover, :checked or ::after, so the recipes take state as options (pressed, focused, checked, disabled) and give small targets a hitSlop instead of a larger box. LibreLifts moves its components onto them at the same time, so the two apps' buttons come out alike.

Decision

  • Button, TextField, NumberField, SetRow's done tick and Problem's action take their classes from the recipes: button(), field(), label(), input() and checkbox(). They stay the app's own components, in apps/app/src/components, with the same props, and ConfirmButton keeps asking twice.
  • Button's variants map onto the recipe's: primary → default, secondary → outline, danger → destructive, quiet → ghost, and small → the compact size.
  • State is passed in, not written as a variant class. A component keeps whether it is pressed or focused and passes it to the recipe, and passes the recipe's hitSlop on.
  • A recipe's text classes are not passed through cn. tailwind-merge does not know Spotstrap's type scale, and takes text-body for a colour that a later text-foreground replaces. Classes a caller adds for layout are merged into the box classes only.
  • Screen, Section, Card and Note stay as they are: they are layout, and Spotstrap has no recipe for them.

Consequences

  • The app's controls look like LibreLifts' and like the website's Spotstrap components, and change with them when Spotstrap is updated.
  • Some controls look different: quiet buttons are no longer green, a destructive button is filled once it asks, buttons are 44 points high instead of 48, and their text is 17 points and medium instead of 16 and semibold.
  • A recipe returns strings, so a mistake in one shows up only on screen. The simulator check stays the test.
  • Variants the recipes do not have, such as a quiet button in the brand colour, are no longer available without a change to Spotstrap.

LibreBars

Clone this wiki locally