Guidelines
Principles, foundations, desktop and touch, and which component to reach for.
These guidelines are for the apps built on @orz/ui: tools people keep open all day, used at a desk with a mouse and a keyboard, and on a phone with a thumb. Storybook says what each component takes; these pages say when to reach for it, how big it is on each kind of pointer, and what to do around it.
How a page reads#
Each page opens with its rule in one sentence. A live example follows, built from the real components, with the file it came from behind Source; Pointer and Touch above it preview either kind of pointer on any device. Then come Do and Don't pairs, a decision table where a choice has more than two branches, what changes on each platform, and the Storybook pages for the components the page is about. A page leaves out the parts it has nothing for.
Sources#
Where a page quotes a number from outside this library, it links where the number comes from. The library's own sizes, such as row heights, breakpoints and durations, are its choices and link nothing.
- Apple's Human Interface Guidelines for how a platform behaves on iOS and macOS: hit targets, safe areas, sheets and popovers.
- GNOME's Human Interface Guidelines for desktop tools: design for people's goals, avoid confirmations and offer undo, keep the interface quiet.
- WCAG 2.2 for the numbers that are law somewhere: contrast, target size, visible focus.
Pages#
Foundations
- ColorA token names a role; the user's theme picks the colour. Every surface, line and text reads one.
- TypographyOne sans family at three sizes, a monospace for what is copied, and numbers that line up.
- Layout & spacingA 4px grid, space that grows with the distance between ideas, and one breakpoint between a phone and the rest.
- SurfacesThe page's ground, the cards that stand on it, the panes an app is built from and the frames set in their flow: what each holds, and what never goes inside what.
- DensityCompact by default for a mouse, larger by itself on touch. Step down a size only where many controls share a row.
- MotionShort, quiet and only where it explains a change: where something came from, or where it went.
- IconsLucide, at the size of the text beside it, in the colour of that text. An icon alone always carries a name.
- ThemingThe user picks the theme, the mode and the variant; the app offers the choice, remembers it, and never overrides it.
- StylesA style draws the components: their shape, type, density and motion. The user picks it beside the theme, and no style may move what keeps a screen usable.
Platforms
Patterns
- Choosing a controlSwitch, Checkbox, RadioGroup, Select: they all pick a value. The right one tells people when it takes effect and how many they may pick.
- Actions & buttonsOne primary action per surface, the rest quieter, and the rare ones in a menu. A button's look says how much it matters.
- FeedbackToast, inline message or dialog: where a result is said depends on whether people have to do something about it.
- OverlaysDialog, Sheet, Popover, DropdownMenu, HoverCard and Tooltip: how much each one interrupts, and what it becomes on a phone.
- FormsA form is a column of labelled fields with one submit. Labels stay visible, errors sit under their fields, and nothing is lost on the way out.
- Loading, empty & errorLoading, empty, failed and loaded each look different and say so. Nobody should have to guess which one a blank area is.
- Destructive actionsUndo over confirm: make a destructive action reversible and offer Undo, and confirm only what cannot be taken back.
- NavigationTabNav, Breadcrumb, NavList, Tree and Tabs: where the reader is, and how they get somewhere else, drawn the same way in every app.
- Code blocksCode in a document sits in a frame that copies it, says what it is, and keeps a long block from burying the text around it.
- Comparing imagesMediaCompare for two versions of a picture in the page: side by side, swipe, onion skin or difference, at one scale; an author's image pair in Markdown, and MermaidCompare for a diagram.
- Long contentA long block in a document is cut at one height, fading out above a Show all bar: code shows the rest in place, a patch or an embedded file opens in the viewer.
- ReorderingA list ordered by hand: a drag handle and a pair of move buttons on every row, the app's rules for where a row may go, and one move handed over each time; and a board, whose cards move between its columns.
- SearchA box people search from keeps the queries they ran and draws values as the app does: which boxes keep them, in which bucket, when a query counts as searched, how a value looks, the words an app finishes, groups and the status line, where the panel goes, slash commands, and a box that only jumps.
- ToolbarsA row of commands that fits the width it is given: what does not fit goes into a ⋯ menu, in an order the caller sets, and comes back as the room does.
- Writing MarkdownWhere people write more than a line, a comment, a description, a note, give them MarkdownEditor: files go in where they are pasted, and the reader keeps a plain text box if they ask for one.