This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index at /llms.txt, or add .md to any page's URL.
Recipe: a numeric readout
Use tabular digits for numeric columns or values changing in place, including progress percentages.
Use tabular digits for numeric columns or values changing in place, including
progress percentages. Use default spacing for prose, labels and static standalone
statistics. See tabular numbers for
layout limits and host exceptions.
A timer's or an updating total's big number is deliberate design: it may set its
size. -exact-fit="shrink" with white-space="nowrap" keeps it on one line.
Add a big number readout
Paste this into Claude, Cursor, Codex, or another agent.
contract
component Water
state ml = 750
state goal = 2000
action drink(amount: number)
ml = ml + amount
view
column align-items="center" gap=4 padding=24
text `${ml}` font-size="4.5rem" font-variant-numeric="tabular-nums" -exact-fit="shrink" white-space="nowrap"
aria-label=`${ml} of ${goal} ml` testId="total"
text `of ${goal} ml today` color="-exact-secondary-label"
row gap=12 margin-top=16
button press=drink(250) buttonStyle="bordered-prominent" testId="add-250"
text "+250 ml"
button press=drink(500) buttonStyle="bordered" testId="add-500"
text "+500 ml"
contract-test
test "the total grows"
expect text "total" == "750"
tap "add-250"
expect text "total" == "1000"
•
A size in rem ("4.5rem") follows the reader's text size (Dynamic Type on iOS); a
bare number is fixed points. bun <exact2>/scripts/no-tells.mjs passes a size on a
node with tabular-nums, and flags one anywhere else. Do not add tabular digits
just to pass this check; a deliberate static display size can carry a
// no-tells: <why> annotation.
•
-exact-fit="shrink" draws a line too wide for its box smaller until it fits, as
UIKit's readouts do (adjustsFontSizeToFitWidth): down to half its size, or a display
size down to the reader's text size. Without it, a stopwatch's 00:48.12 at the
largest accessibility size ran off both edges (only :48. showed). It never caps the
size: a line that fits keeps it. Every host lays it out at the same scale.
•
Only the number's size is designed. Its colour is unsaid or the accent
(color="AccentColor"), never a hex, which stays the same in dark mode; its label
stays the platform's (color="-exact-secondary-label"), and a title is a heading,
never a big font-size.
•
Android follows the default text paint at the displayed size. On Android 10 with Roboto at 12 sp and 320 dpi, the native 8 advances 14 px and the other tabular digits advance 13 px.
•
Tabular digits stabilize equal-length digit changes, not 99 → 100; reserve
space for the formatted range when adjacent content must stay still.
•
Give the readout an aria-label that says what the number is; VoiceOver reads the
label, not the digits alone.
Is this helpful
Last updated November 25, 2026