# 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](https://developer.apple.com/design/human-interface-guidelines/) for how a platform behaves on iOS and macOS: hit targets, safe areas, sheets and popovers.
- [GNOME's Human Interface Guidelines](https://developer.gnome.org/hig/) for desktop tools: design for people's goals, avoid confirmations and offer undo, keep the interface quiet.
- [WCAG 2.2](https://www.w3.org/TR/WCAG22/) for the numbers that are law somewhere: contrast, target size, visible focus.

## Pages

- [Principles](/ui/guidelines/principles/index.md): The rules the rest of the guidelines follow from. When a page is silent, these decide.

### Foundations

- [Color](/ui/guidelines/foundations/color/index.md): A token names a role; the user's theme picks the colour. Every surface, line and text reads one.
- [Typography](/ui/guidelines/foundations/typography/index.md): One sans family at three sizes, a monospace for what is copied, and numbers that line up.
- [Layout & spacing](/ui/guidelines/foundations/layout-and-spacing/index.md): A 4px grid, space that grows with the distance between ideas, and one breakpoint between a phone and the rest.
- [Surfaces](/ui/guidelines/foundations/surfaces/index.md): The 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.
- [Density](/ui/guidelines/foundations/density/index.md): Compact by default for a mouse, larger by itself on touch. Step down a size only where many controls share a row.
- [Motion](/ui/guidelines/foundations/motion/index.md): Short, quiet and only where it explains a change: where something came from, or where it went.
- [Icons](/ui/guidelines/foundations/icons/index.md): Lucide, at the size of the text beside it, in the colour of that text. An icon alone always carries a name.
- [Theming](/ui/guidelines/foundations/theming/index.md): The user picks the theme, the mode and the variant; the app offers the choice, remembers it, and never overrides it.
- [Styles](/ui/guidelines/foundations/styles/index.md): A 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

- [Desktop & pointer](/ui/guidelines/platforms/desktop-and-pointer/index.md): Hover hints, the keyboard reaches everything, and shortcuts speed up what is already on screen.
- [Touch & mobile](/ui/guidelines/platforms/touch-and-mobile/index.md): Hit areas and room between targets from the components, content clear of the notch and the on-screen keyboard, and no gesture as the only way.

### Patterns

- [Choosing a control](/ui/guidelines/patterns/choosing-a-control/index.md): Switch, Checkbox, RadioGroup, Select: they all pick a value. The right one tells people when it takes effect and how many they may pick.
- [Actions & buttons](/ui/guidelines/patterns/actions-and-buttons/index.md): One primary action per surface, the rest quieter, and the rare ones in a menu. A button's look says how much it matters.
- [Feedback](/ui/guidelines/patterns/feedback/index.md): Toast, inline message or dialog: where a result is said depends on whether people have to do something about it.
- [Overlays](/ui/guidelines/patterns/overlays/index.md): Dialog, Sheet, Popover, DropdownMenu, HoverCard and Tooltip: how much each one interrupts, and what it becomes on a phone.
- [Forms](/ui/guidelines/patterns/forms/index.md): A 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 & error](/ui/guidelines/patterns/loading-empty-and-error/index.md): Loading, empty, failed and loaded each look different and say so. Nobody should have to guess which one a blank area is.
- [Destructive actions](/ui/guidelines/patterns/destructive-actions/index.md): Undo over confirm: make a destructive action reversible and offer Undo, and confirm only what cannot be taken back.
- [Navigation](/ui/guidelines/patterns/navigation/index.md): TabNav, Breadcrumb, NavList, Tree and Tabs: where the reader is, and how they get somewhere else, drawn the same way in every app.
- [Code blocks](/ui/guidelines/patterns/code-blocks/index.md): Code 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 images](/ui/guidelines/patterns/comparing-images/index.md): MediaCompare 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 content](/ui/guidelines/patterns/long-content/index.md): A 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.
- [Reordering](/ui/guidelines/patterns/reordering/index.md): A 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.
- [Search](/ui/guidelines/patterns/search/index.md): A 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.
- [Toolbars](/ui/guidelines/patterns/toolbars/index.md): A 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 Markdown](/ui/guidelines/patterns/writing-markdown/index.md): Where 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.

### Content

- [Writing](/ui/guidelines/content/writing/index.md): Voice, labels and capitalisation: the words on buttons, in dialogs and in messages, written the way a person would say them.
- [Accessibility](/ui/guidelines/content/accessibility/index.md): Contrast, focus, keyboard, target size and names: what every screen has to meet, with the WCAG 2.2 criterion behind each number.
