Density
Compact by default for a mouse, larger by itself on touch. Step down a size only where many controls share a row.
Use the default size, step down only inside a dense row or toolbar, and leave touch to the components. The default is drawn for a mouse, so a screen shows as much of the work as it can; on a coarse pointer the same controls, drawn the same, take hit areas and room between them without the app asking.
The run's toolbar and each job's Log are a size down, because they repeat and sit next to content; the two actions that close out the panel are the default size. Press Touch above the example to see the same tree make room for a thumb.
Sizes#
Every number on this page is the default style's. Another
style draws the same sizes at its own heights, and a coarse
pointer adds the same room around them all the same. Every size of Button, as the default style
draws it:
| Size | Height | Use |
|---|---|---|
lg | 32px | The one action a page or empty state is for; a call to action on a landing page |
| default | 28px | Forms, dialogs, a panel's own actions: anything a person reads before pressing |
sm | 24px | A toolbar of text buttons, a filter row, actions inside a card |
xs | 22px | An action repeated on every row of a list or table, inline with text |
icon, icon-sm, icon-xs, icon-lg | 28, 24, 22, 32px square | The icon-only counterparts of the four |
- lg
- default
- sm
- xs
- Lint
- icon-*
Each size where a demo uses it: Compose on Mail's phone layout, the profile form's buttons in Settings, Recording above a pull request's test log and Revoke… on each access token, each job's Log in the panel above, and Archive at every icon size.
Input and Select's trigger are 28px, the
default, so a field and its button line up on one row. Select's trigger also comes in sm for a
toolbar.
Controls side by side in one row take one size, so their tops and bottoms line up in every style:
a SegmentedControl takes size as a Button does, and beside sm buttons is sm too; next
to a field, which has only the default size, a button keeps the default. A Toolbar gives every
part in it the bar's size, so a row of commands, with a segmented control among them, is one
Toolbar rather than parts sized one by one, as the bar over each demo is.
Keep the default size and let a coarse pointer add the room around it. One layout serves the mouse and the thumb.
Pass size="lg" when the screen is narrow, or branch on width to make touch targets. A narrow
window on a desktop is still clicked, and a tablet is wide and still touched.
Information density#
- A row holds one primary line in
text-uiand at most one secondary line intext-ui-sm. More than that belongs in the detail view. - Repeated per-row actions are small and quiet (
ghost,xs). One that destroys and asks first isdestructiveatsm, whose tint stays quiet until it is needed: the Settings demo's Revoke… on each token. A single action for the whole view is default size and stands apart. - On a pointer, a row's secondary actions can wait in a
DropdownMenubehind a⋯button; they are not hidden until hover, which leaves keyboard and touch users nothing to press. - Dense is not cramped: rows keep
gap-2between their parts and a 28px row height with a mouse, so a misclick lands on the right row.
Inbox
Each conversation is a subject over its senders. Its actions wait behind a quiet ⋯ that is always
there, and Compose, the one action for the whole list, is the default size above it. Archive a
conversation, then press Undo in the toast.
On each platform#
- Pointer. The sizes above. Neighbouring controls can sit 4px apart; a mouse lands reliably on a target of WCAG's 24px minimum (2.5.8).
- Touch. On a coarse pointer
@orz/ui'stouch:variant keeps each control as it is drawn, gives it an invisible 36px hit area, and keeps neighbouring targets that far apart: between the 28pt Apple allows and the 44pt it gives a control by default (Apple HIG: Accessibility), and never below that 24px minimum. Touch & mobile has the size of each part. A row you build yourself makes the room the same way:touch:min-h-touch.
In the demos
- TasksA table row is a key, a title and its badges, with the row's ⋯ always drawn. Press Touch in the bar above, and the rows make room for a thumb around their controls.
- MailA row is a sender, a subject and one line of snippet. Press Touch in the bar above, and the toolbars and the checkboxes make room for a thumb with no layout of their own.