Patterns
Forms and settings
When a change takes effect (at once, on Save or through a button that names it), settings that apply at once, groups of fields saved together, forms in dialogs, the large one-pass form dialog, validation, long values in fields, option height and the danger zone.
What a change is decides when it takes effect: a choice applies the moment it is made, text waits for Save, values that only work together share one Save, and a side effect that can't be taken back is a button that names it. A form that creates something is a dialog, never a side panel, however long it is (Page structure). A form in a dialog has Cancel and the submit button in its footer. A large form filled in one pass, such as registering an app, opens as a wide dialog with a section list.
When it applies
Settings pages, forms in dialogs and drawers, and large configuration forms. Which control to use for a value is in Choosing a component.
Structure
Fields
- Put the label above the field and, under it, a helper text only when the field has a consequence the label doesn't say: what is lost, who sees the value, or how to recover. Otherwise nothing: no instruction that repeats the label ("Enter your email"), no example the placeholder can show, no tagline (Writing, Field). In code it is a
FieldDescriptionholdinghelperText(…, { why, about }). - Mark optional fields "(optional)", and don't mark required ones: marking the optional ones is enough, and a form with both marks says the same thing twice. Keep
aria-required(orrequired) on a required control, so a screen reader still says so. In Chinese, write the marker in full-width brackets straight after the label, with no margin before it: a full-width bracket already carries its space (Field). - In a form saved with a button, reserve the line under a field for its helper text or its error, so the form doesn't move when an error appears. A setting that applies at once reserves none (Settings that apply at once).
- Give a setting a description only when it says a result the title doesn't: something lost, who sees it, or how to recover. It states that result, not a repeat of the title: the title already names the setting.
- Put a checkbox, a radio or a switch 8px before its label, centered on the label's first line, and at the end of a settings row centered on the whole row (A setting's row). raft-ui places it there (
FieldItem, a checkbox's or radio's<label>row,ListRow); never nudge it with a margin (Alignment). The switch stays 50 × 30 and the checkbox and radio 20px, on a phone and a desktop alike.
A setting's row
A settings page is read as one list of settings, so every setting is drawn the same way, whatever control it has (cindyz, 2026-11-09, #proj-raft-ui:#220).
- Group a page's settings into sections: a
SectionHeader(its icon and name, and a hint only where it says something the name doesn't, Writing), then aListRowGroupofplainListRows, one row per setting. The group draws the card and the hairlines between rows. Don't draw a card of your own with a divider inside it, and don't put aListRowGroupinside aCard: a second inset makes the rows in it start further in than the rows of every other card on the page. - A row has the setting's title (
ListRowTitle), what it does (ListRowDescription, wrapping) and, for a setting that applies at once, itsSaveStatusline, which shows only when a change failed; then its control. Every row's title and description look the same, so a row never looks like a heading of the row under it. - Put the control at the row's end, centered on the whole row: a switch, a button, a segmented control or a select, whatever its options say. A select is as wide as its longest option, at least 11rem (
w-44) and at most 20rem, as a segmented control is as wide as its segments; past 20rem its value ends in an ellipsis, and its list shows every option whole. Every control on a page then sits in one place, as in macOS's and Windows's settings; on 2026-11-09 a select whose options were phrases went under the row's text so as not to cut its value, but on one page some controls at the end and some under the text read as a layout that slipped, and at its own width a select cuts almost nothing (cindyz, 2026-11-12, #triage:c95a5e53). An option that would need more than 20rem usually repeats the setting in every option: say the condition once in the description and keep only what differs in the options ("After 5 min away", not "If I'm away from my computer for 5 min and it's still unread"). Where the row itself is narrow (under 32rem of its own width, a container query on its group: on a phone, or in a narrow settings column on a wide window), a segmented control or a select goes under the text, at mostmax-w-smwide: beside it, it would squeeze the title and description into a sliver (Responsive). A switch stays at the end. - What belongs to a setting but isn't its control (a status badge, a hint) goes in the row's body under its text, so it stays with the setting it explains. What a choice opens (quiet hours' times, a server's channels that have their own level) goes in rows of their own right under it: in the same row it would make the row taller and pull the row's control away from the title it belongs to.
- A row that belongs to the setting above it follows that setting: no hairline between them, and less space above it (
ListRow attached: the setting's own bottom inset, 12px, instead of 24px and a hairline). A hairline says "another setting", so between a setting and what it opens it splits one thing in two (cindyz, 2026-11-10, #proj-raft-ui:4ae1a74e). The setting's row doesn't change: its switch stays centered on its own title and description. - A section may hold more than one group, split by topic. In Appearance, the message font size and its preview are one group, and the switches for what the app shows (live agent activity, the agent's model, hiding empty sidebar sections) are another: a setting and its preview are one thing, and the switches are another kind of option, so a hairline between them would join two topics into one list (cindyz, 2026-11-10, #proj-raft-ui:4ae1a74e). Put the groups under the section's one header, 12px apart (
stack-y-3), with no hairline joining them (ListRow). Give a group a header of its own only when it is a section of its own. - A card of its own is for fields saved together (a profile, a password: Settings saved together) or for content that isn't about one setting. A preview of one setting, such as the message font size's, is a row of its own right under it, in the same group, and belongs to it the same way (
attached).
When a change takes effect
Ask these in order; the first yes decides (stdrc, 2026-10-29). Each kind of change gets the commit it needs: a choice is complete when it is made, text only when people stop typing, grouped values are invalid halfway, and a side effect can't be taken back.
- Let how far a change reaches decide whether it is confirmed or can be undone, never whether it needs Save (Feedback): Save explains nothing about what follows, a confirmation does. A checkbox and Save is not a confirmation.
- Apply filters, sorting and view switches at once, with no Apply button: they change only what the person sees.
Settings that apply at once
- Use a switch, a segmented control or a select for a setting that stands alone (the appearance, the time zone, muting a server, whether the public page is on), and apply each change as it happens. Don't add a Save button: on one choice it adds a step and checks nothing. This holds when several such settings share a card: each one saves itself, and the card has no Save.
- Show nothing when the change is stored, and reserve no line for it: the control showing its new value is the confirmation, as in macOS's and iOS's settings. A "Saved" repeats what the control already shows, and a line kept for it, empty most of the time, made every such row taller than its neighbors and read as stray space (cindyz, 2026-11-10, #proj-raft-ui:4ae1a74e). This replaces the way chosen on 2026-10-30 (Kirby's option A, which stdrc agreed to, #proj-raft-ui:401f3241): "Saved" for a moment, with its line kept while empty so the card didn't jump when it came and went. With nothing shown on success, nothing comes or goes, so no line needs keeping; this is that thread's option C.
- When the change fails, put the control back to its old value, so it never shows a value that isn't true, and say what failed on a line that appears under it, until the next change. The line is 4px under the control, the same for a select, a segmented control and a settings row with a switch, where it goes under the description, or right under the title, in the description's place, when the row has none (cindyz, 2026-11-10): one distance reads as one kind of line on every setting (Kirby, agreed by stdrc, 2026-10-30). The setting grows by that line while it shows; a switch at a settings row's end stays centered on the whole row. raft-ui draws this line (SaveStatus).
- Say where a section's settings are stored ("Saved on this device") once, for the section: in its header or in a line under its group, not on every row. Said on each row, it repeats one fact as many times as there are settings and makes each row taller (cindyz, 2026-11-10, #proj-raft-ui:4ae1a74e).
Settings saved together
- Put fields that are edited together in one card: a profile, a password, a server's name and description. Put Save under the fields, at the start of the line, before any other button of the card. Save applies only that card, so a half-edited card never saves another one.
- After a save, change the button to "Saved" with a check for a moment.
- Turn on a feature that needs its configuration before it can be on (sending events to an app, which needs an address; asking new members to accept an agreement, which needs its text) with a checkbox, its fields under it and one Save for the group. Don't use a switch that only reveals the fields: a switch that shows on while nothing is on says something untrue.
Forms in a dialog
- Put Cancel and the submit button at the bottom of a form in a dialog. Cancel is a ghost button there, framed when the buttons stack full width (Dialog), and takes an ink border on a page (Button). Cancel comes first; the submit button is the screen's pink button and names the action it performs, usually the title's verb: Create in Create channel; an Edit title's button is Save (Writing). Both are
size="lg", the height of the fields above them (Spacing). - Offer public or private, and any other answer whose result needs saying, as a radio group with one line under each answer: "Anyone in the server can find and join it", "Only people invited can see it". The line puts the result next to the choice, which a segmented control has no room for (RadioGroup).
- When one section of a dialog or a drawer saves on its own, because the rest applies at once (a channel's name and description among its switches), put its Save under the section's fields at the start of the line, Save first, as on a settings page. At the end of the footer it would read as saving the whole dialog.
- Make a form with a few fields a small dialog, the default
size="md", 448px wide: creating a channel, an agent or a task. A form whose content needs more width, such as key-value rows or a command, takessize="lg", 640px (Dialog).
The large form dialog
A large form filled in one pass, such as registering or editing an app, opens as the wide dialog (Dialog): centered, 896px wide, with a fixed height of 760px or the window less 32px, whichever is smaller. It doesn't go to a settings page or a drawer: a form with many fields has to be seen as one whole, not as a strip along the edge.
- Make the header (the header height: 44px with a mouse, 56px on a touch screen) the item's logo, the title and ×. The title is the words that opened it (Register app), or Edit and the item's name when editing. Don't put the submit button in the header.
- Put a strip under the header for what must stay in view while the form scrolls: the form's error, or a secret shown once.
- Put a section list on the left, 208px wide, so people can jump around a long form (sidebar rows; the section being read is a yellow sticker and follows the scroll), and the sections on the right (FormSection: a small heading, a status chip, one line of description, and a hairline between sections).
- Inset the sections from the pane they scroll in on every side, the top included: the pane's scroller pads its content by the surface's padding (
--surface-inset, 20px on a touch screen and 16px with a mouse), so the first section's heading starts as far below the header's seam as the sections are from the section list and the dialog's edge. A section starts flush with its container and keeps no room above itself, so the room is the pane's to give: without its top inset the first heading and its status chip met the seam under the header and ran under the scrollbar's end (Artea, #triage:#644, slock #17004). Put the padding on the scroller's content, not on the scroller, so the scrollbar stays at the pane's edge. Below 768px the dialog's body already sits on the screen's margin and adds none. - Put Cancel first and the pink button last in the footer.
- Don't close the dialog when someone clicks outside it, so a stray click doesn't throw away a long form. ×, Esc and Cancel close it.
- Below 768px, leave out the section list.
- When creating, show only the sections that can be filled in before saving. Sections about an item that already exists (distribution, deletion) appear after it is saved.
- Write an action inside a section as an ordinary row, with the description on the left and the button on the right, not as a card inside a card.
Rules
Validation
- Check the fields when the form is submitted, not while people are still typing. A field whose value is wrong when the form opens shows its error at once.
- Show an invalid field with a
danger-strongborder, and put the error in its reserved line, saying how to fix it. - Put a problem with the whole form, such as a failed request, in an orange banner inside the form (Banner). Don't repeat the field errors in it.
- Don't show a toast for a validation error: it disappears, and the error has a place of its own under the field.
Long values in fields
A value can be any length: a pasted link with no spaces, a long Chinese name, a label translated into long words. Nothing in a form grows wider than its field, and no field grows wider than its dialog, its drawer or the screen, down to 320px (Responsive layout). What gives way depends on whether the part is one line by design.
- A label, helper text or error wraps, breaking inside a word when the word alone is wider than the line. It's what explains the field, so cutting it off would hide the part people need. This holds for the label beside a checkbox, a radio or a switch too.
- A value in a one-line control truncates with an ellipsis: the selected value of a Select, a chip, a text prefix. The control keeps its height, so the form doesn't move as values change (Spacing). The whole value is the part's
titlewhile it is cut off, and stays its accessible name. - A value people type scrolls inside its field. An Input keeps its text on one line and scrolls it; a Textarea wraps it. A Combobox's value is both: it scrolls while people type in it, and truncates like a selected value otherwise. The input's
titleis then its description, not its name, so it still needs a label. - An option in a list wraps to two lines, then truncates, with its whole text as the
title. Two lines let people tell apart two long values that begin the same way, which one line can't do, while every option stays short enough to scan. The selected value in the trigger is still one line. - A chip truncates at the width of its field, and its remove button stays visible at its end.
- A text prefix in an InputGroup takes at most half the field, and truncates past that, so there is always room to type.
- A list is never wider than the screen less 8px on each side. It is at least as wide as its field and at least 220px. A Select's or a Combobox's list grows to fit a longer option up to 24rem (or the field's width, when that is wider); a ComboboxSelect's list stays the field's width. Past that, the option wraps.
Every control holds these rules itself, so a form never adds its own min-w-0 or truncate. A control that truncates a value gets its title from useOverflowTitle (use-overflow-title.ts), which sets it only while the value is cut off. Give the hook a stable ref, a ref object or a memoized callback: an inline callback ref rebuilds its observers on every render. A layout that puts a field in a flex row still gives the field's column min-w-0, since a flex item won't shrink below its content without it.
Option height
An option's height follows its content, and its padding is constant. This holds for every row in a popup list: an option of a Select, a Combobox or a ComboboxSelect, and an item of a DropdownMenu or a ContextMenu, with a check mark, a radio mark or neither.
- One line is 36px on a touch screen and 34px with a mouse (
option-height), the desktop row height. The rows of a popup list are the one exception to 44px touch targets: they touch each other, so their hit area can't grow past the row, and a full-width row is easy to hit and a wrong tap is easy to see and change (Spacing). The space above and below the text is what that row leaves around one line of the option's type: 6px around a desktop's 22px line (in a 34px row), 8px around a touch screen's 20px line. - A second line adds its own height and nothing else, whether the label wraps (Long values in fields) or a description sits under it. The space above and below stays the one-line option's, so a two-line option looks as loose as its neighbors instead of cramped, and two of them never touch.
- A list never sets its options' height. Options in one list may differ in height; they never differ in padding. Don't give an option a fixed height, a fixed line box or
leading-none, and don't give a list a fixed row size: one line would fit and the second would be cut off or squeezed. A list that only shows some of its options at a time measures each one. - A part beside the text fits the line: a 16px icon, a check mark, a count. It doesn't make a one-line option taller.
- The highlight sits 4px inside the popup, with
radius-chip: that close to the popup's edge it follows the popup's corner, so the space around it is even at the corner as along the sides. A separator leaves the same 4px above and below it (Shape).
The components hold this themselves (py-option-inset, the space an option-height row leaves around one line, with min-h-option as the floor for an option with no line of text), so a product never pads an option of its own. The menus don't tighten their options on a short window (600px tall or less): a one-line item keeps its option-height floor there (36px on a touch screen, 34px with a mouse), so tightening would only squeeze items of two lines. A short screen, such as a phone held sideways, scrolls a menu a little more instead.
Danger zone
- Put the danger zone at the end of the page, away from the settings people change often.
- Use orange for actions that interrupt but can be undone (stop, leave, reset) and red for actions that cannot be undone (delete) (Color). As a button, such as a confirmation's, that is Button's
warningordanger. In a card of action rows, such as the end of a channel's details, only the action that can't be undone is colored, red (ListRow'stone="danger", on the title and the icon); the others are in ink, and their confirmation's orange button carries the warning: orange beside ink in one card read as a mix-up, and a color on most rows warns of none (ListRow). - Draw a single destructive action with a title and a one-line description, such as removing an App at the end of its details, as one row: the text first, the button at the row's end, aligned to the top of the title. It isn't centered on the row as a setting's control is: the description can wrap to two lines, and the button belongs with the title. Narrower than 640px, the button goes under the text. A button label that includes the item's name moves to the next line when it doesn't fit beside the text, still at the row's end, and truncates if it is still too long (Button) (cindyz, 2026-11-27, #wg-apps-ux:95b254cb).
- Ask for the server's slug to be typed before deleting a server, because it deletes everything in it for everyone. Confirm other deletions with a dialog that names what is deleted (Feedback).
Prerequisites
- Don't show a form that can't be used yet. When something is missing, say what, and offer the way forward: connect a computer first, then create the agent.