Patterns
Which control to use, settings rows, overlays, the command menu, and accessibility.
Choosing a control
| The choice | Use |
|---|---|
| On or off | Switch |
| 2–4 short options, changed while working | Segmented control |
| Several options where seeing them helps | Option cards, three across |
| Many options known by name | Select, or Combobox when it needs search |
| A number in a useful range | Slider and a number field |
| A value set by dragging | The drag and a typed input |
| An action | Button, or an icon button with a tooltip in a bar |
Every value the user can drag can also be typed. In CodeImage's Animate timeline you can drag the edge of a step or type its duration. The easing curve is drawn but cannot be dragged. A custom curve is typed as text, because dragging bezier handles was rejected as too fiddly.
Do not use a dropdown to manage things the user is building, such as steps, tabs or layers. CodeImage replaced its step dropdowns with a dashed "+ Step" card the same size as a real step, placed where the new step will appear.
Inside a modal dialog, avoid Select. Its list opens in a portal outside the dialog, where assistive technology cannot reach it. Use a segmented control, a switch or cards instead.
Settings
- 01Title. 14px, weight 500, primary tone.
- 02Description. One line, 12px, secondary tone.
- 03Control. Right-aligned. Segmented, switch or cards.
- 04Group island. Rows touch inside it. No lines between them.
- 05Default tag. One word, 11px, on the current default.
A settings row is a title, one line of explanation, and the control on the right. The rows of a group sit together on one island with no lines between them. Below 900px the control moves under the text.
The settings dialog has two panes: search and sections on the left, rows on the right. The current section is marked with a fill, not with blue. The title is a breadcrumb ("Settings / Appearance") and there is no footer, because every change is saved immediately. It is 1000×680 on a desktop. On a phone it fills the screen less an 8px gutter, and the sections wrap three to a row. The kit builds it with the Dialog layout parts.
Options that are not the default yet live in an Experiments section. The current default carries a Default tag, and one "Restore defaults" action resets everything. When an experiment wins, it becomes the default and the option it replaced is deleted, not kept as a setting.
Option cards
Option cards are for choices where a picture helps, such as layout, colour mode or window style. A card has no border, a field fill, and a 68px preview. When selected, its fill goes up one step and it gets a 2px blue ring.
The preview is a schematic drawn in the option's own colours, not a miniature of real content. CodeImage tried tiny code previews for its themes, and at card size every theme looked the same. A strip of palette colours was tried as well, but it showed the colours without showing how the theme looks.
Overlays
| Overlay | When | Backdrop |
|---|---|---|
| Tooltip | Name an icon, explain a value | None |
| Popover | Pick a value for one row | None |
| Menu | Choose an action | None |
| Command menu | Find anything by name | None |
| Sheet | A panel on a phone | None |
| Dialog | Settings, or a decision that blocks | Scrim |
A picker opens over the panel that holds it, anchored to its row. It does not push the rows below it down, and it does not dim the page. The user is choosing a value for the content, so the content must stay visible.
A dialog is for settings and for decisions the user must make before continuing, such as reviewing detected secrets before an export. It is not for asking "are you sure?" about something that can be undone.
Escape closes only the innermost layer. In CodeImage, pressing Escape on a segmented control inside Settings once closed the whole dialog.
Command menu
⌘K, or Ctrl+K outside Apple platforms, opens the command menu in every layout. It floats at the bottom centre, six rows tall, with no scrim, so the content stays in view while you browse.
It lists every option of every visible control, every action and every setting. It reads the same data as the controls, so a new setting appears in it without extra work. Moving through the rows previews each option on the content. Enter applies it and Escape puts the old value back. A short hint in the search row says so: ↑↓ preview · ↵ apply · esc cancel.
Actions in dialogs and toasts
Close and Confirm go on the right of the footer. A third, minor action is a small ghost button with an icon on the left. A toast's action is an inline text link. CodeImage first tried full-width buttons in a toast and a dialog, and they were rejected: "i pulsanti messi così sono orrendi".
Announcing new things
A new feature gets a small blue dot on its control, at most three at a time across the app, and the dot never animates. A release is announced by a small card in the bottom-left corner, once per release. A blocking "What's new" dialog was replaced, and so was a toast that said "Settings has 7 new things".
Accessibility
- Text contrast is at least 4.5:1 below 18px. Icons, rings and control edges are at least 3:1. Both themes are checked.
- Every control works from the keyboard. Pickers and cards open with Enter and Space. A list previews on focus just as it does on hover.
- There is one focus ring: 2px, offset 2px, shown on
:focus-visible. - Closing an overlay returns focus to whatever opened it.
- On a phone, opening a dialog does not focus a text field, so the keyboard does not cover the dialog.
- Every icon button and field has an accessible name. Colour is never the only signal.