Skip to Content
CodeUI

Patterns

Which control to use, settings rows, overlays, the command menu, and accessibility.

Choosing a control

The choiceUse
On or offSwitch
2–4 short options, changed while workingSegmented control
Several options where seeing them helpsOption cards, three across
Many options known by nameSelect, or Combobox when it needs search
A number in a useful rangeSlider and a number field
A value set by draggingThe drag and a typed input
An actionButton, 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

Fig. 1Anatomy of a settings row
Editor
Layout
Where the controls sit.
SidebarDock
Navigation
Default
How the sidebar moves between sections.
  1. 01Title. 14px, weight 500, primary tone.
  2. 02Description. One line, 12px, secondary tone.
  3. 03Control. Right-aligned. Segmented, switch or cards.
  4. 04Group island. Rows touch inside it. No lines between them.
  5. 05Default tag. One word, 11px, on the current default.
Every settings row has the same five parts. Point at a number to find it.

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.

Do
Fleet
Dracula
Night Owl
A schematic in each option's own colours. Three themes, three different cards.
Don't
function Count() { const [c, s] = return <div>
Fleet
function Count() { const [c, s] = return <div>
Dracula
function Count() { const [c, s] = return <div>
Night Owl
A miniature of real code. At this size every theme looks like the same grey text.

Overlays

OverlayWhenBackdrop
TooltipName an icon, explain a valueNone
PopoverPick a value for one rowNone
MenuChoose an actionNone
Command menuFind anything by nameNone
SheetA panel on a phoneNone
DialogSettings, or a decision that blocksScrim

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.

Do
Aspect ratio
Free ▾
Background
Gradient ▾
Signature
Off ▾
Gradient✓
Colour
Image
The list opens over the panel, anchored to its row. Nothing below it moves.
Don't
Aspect ratio
Free ▾
Background
Gradient ▴
Gradient✓
Colour
Image
Signature ↓ pushed
Off ▾
The list opens inline and pushes every row below it down. The row the user aimed for is no longer there.

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".

Do
Export image
✎ Alt textCloseExport
Close and Export on the right, the primary last. The minor action is a ghost button on the left.
Don't
Export image✎ Add alt textExportClose
Three full-width buttons stacked on desktop. They outweigh the content and blur which action matters.

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".

Do
Line marks
Signature
A quiet dot on each new control, where the user will find it anyway.
Don't
Line marks
NEW
Signature
NEW
Settings has 7 new thingsOpen settings
Loud tags and a card that sends the user away from their work to read about it.

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.

On this page