Typography
One sans family at three sizes, a monospace for what is copied, and numbers that line up.
API Input Card Table TextLink InlineCode
Set the interface in text-ui, step down to text-ui-sm for what is secondary and to
text-ui-xs only for a badge, and up to text-title for a title. Hierarchy comes from size,
weight and the muted colour together, never from a fifth size.
The pull request demo's CI run, at every row of the scale below: the run is the card's title, the
jobs and the review are body text, the column headers and the reviewer are secondary, and the branch,
the commit and retryOnce are monospace. The times line up because they are tabular-nums, and
the review stops at a readable width however wide the card grows.
The scale#
| Role | Classes | Size |
|---|---|---|
| Body, labels, menu items, button text | text-ui | 13px |
| A title: a dialog, a sheet or a page's panel | font-heading text-title font-medium | 15px |
| Secondary: a timestamp, a hint, table text, a module's name in its header | text-ui-sm text-muted-foreground | 12px |
| A count after a label: a row's, a segment's, a command's | text-ui-sm text-muted-foreground tabular-nums | 12px |
| A badge, and nothing else | text-ui-xs | 11px |
| What a user copies or compares: ids, hashes, paths, code | font-mono at the size around it, or text-ui-sm inline | — |
Running text you write yourself, a docs page or a help topic, is prose and has a scale of its
own, so a style can set it apart from the controls around it: text-prose for its paragraphs
with leading-prose between their lines, text-prose-sm and text-prose-xs for what is
secondary, text-prose-lg for a lead, text-heading-3 to text-heading-1 for its headings, and
text-display for a headline. A link in it is a TextLink, in text-link, which is the text's
own colour until a style's palette gives links one, and a name from code in a sentence an
InlineCode. These docs are set in it; inside a tool, a panel's title is text-title. The
components follow the same scale: DialogTitle and SheetTitle are
font-heading text-title font-medium, a CardTitle is a module's name in its ruled header,
font-heading text-ui-sm font-semibold, a Badge is text-ui-xs, and a count after a label is
a part drawn as the scale says: NavListCount and TreeCount at a row's end,
SegmentedControlCount and ToolbarCount in a segment or a command, those two in the label's own
colour once it is pressed.
Family#
--font-ui is Atkinson Hyperlegible Next and --font-mono OpenMono, then the system's faces.
Atkinson is drawn for legibility: the letters a glance confuses, 0 and O, I, l and 1, are made to
differ. It is set at 105%, where its letters stand as tall and run as wide as the sizes and
spacing around them were measured for. What it lacks of Latin, such as ĉ, ḍ, ŋ and IPA, the
library's build fills in from Noto Sans, scaled and weighted to match. OpenMono draws every symbol,
an arrow or a box-drawing line, one cell wide, and no ligatures, so !== reads as typed. Both
slash the zero the same way, top left to bottom right, so a version reads alike in either face and
neither zero looks like Ø.
styles.css leaves the fonts out so an app with its own pays nothing for them; @orz/ui/fonts.css
loads Atkinson Hyperlegible Next for Latin, Noto Sans for Cyrillic, Devanagari, Greek and
Vietnamese, and OpenMono for monospace Cyrillic, Greek, Latin and Vietnamese. A browser fetches a
script's file only when a page draws its characters. Chinese, Japanese and Korean come from the
page's language, after the style's own Latin face: lang="zh-Hans" names Noto Sans SC or Noto Sans
CJK SC, then PingFang SC and Microsoft YaHei, ja Noto Sans JP or Noto Sans CJK JP, then Hiragino
Sans and Yu Gothic, and so on. None of those is shipped, so the system's, or one your app loads,
draws them; one family for every language would draw Chinese with Japanese glyph shapes.
font-sans and --font-heading are the same family; override --font-heading only if your app
has a display face.
Weight#
font-medium marks a title or a label, the heading over a group of a menu's or a list's rows
among them; font-semibold is for a page heading and a card's title.
Body text stays regular. Bold inside a paragraph is for the one phrase a skimming reader must not
miss, at most once or twice per screen.
Numbers#
Numbers that sit in a column, tick in place, or are compared across rows take tabular-nums, so
every digit is the same width and a column of sizes lines up on the decimal point. The base layer
already gives every <time> element tabular-nums; a date or time you render belongs in one,
which Timestamp draws, and TimestampRange sets a span in them too (see
Writing).
- retry.test.ts
- 512 ms
- fetch-task.test.ts
- 61 ms
- is-done.test.ts
- 4 ms
Set compared numbers in tabular-nums, right-aligned, with the same number of decimals.
- retry.test.ts
- 0.51 s
- fetch-task.test.ts
- 61 ms
- is-done.test.ts
- 4ms
Leave proportional digits in a column, or vary the decimals or the units, so the eye has to read every value to compare two.
Line length and truncation#
Prose sits in at most about 75 characters a line
(Baymard Institute), with max-w-prose, or
max-w-3xl for a page.
A single-line label that may be long takes truncate (or min-w-0 on the flex child that holds it,
or it never shrinks); the full text stays reachable somewhere other than a hover, because a
title tooltip does not exist on a touchscreen. A long unbroken string in a block, such as a URL or
a hash, takes break-words so it cannot push the layout sideways.
Flaky test: retry-once times out on the slow runner
CI, Newcomer, Alice
The Mail demo's subjects, cut to one line in the list. Pick one and the heading beside the list shows it whole, wrapping where it has to: the full text is a click or a tap away, not a hover.
On each platform#
- Pointer. Inputs are
md:text-ui, the body size. - Touch. An
Input,TextareaandHighlightedInputaretext-basebelowmd, and on a coarse pointer at every width, because a tablet is wider thanmd. iOS Safari zooms the page into any field whose text is under 16px when it takes focus (how Safari decides), and does not zoom back out. Keep that in any field you build:text-base md:text-ui touch:text-base. - Both. Sizes are in
rem, so a reader who raises the browser's text size gets larger text everywhere. Text must survive 200% without loss (WCAG 1.4.4); do not set a fixed height on a box that holds text.