Foundations
Spacing and sizing
The 4px spacing grid, hit targets, control and row heights, avatar sizes, header heights and layout widths.
Raft spaces everything on a 4px grid and sizes everything people touch to at least 44px. Headers share one height across a screen, so the seams under them line up.
Principles
- Space on the 4px grid. Use Tailwind's spacing scale: 4px, 8px, 12px, 16px, 20px, 24px, 32px, 40px.
- Touch targets are at least 44px. A control that looks smaller is padded up to 44px by its hit area, not by its drawing.
- Headers line up. Every header on a screen has the same height, so the seam under each one runs as one line.
- The same kind of thing is the same size across an app's tabs. Size an element by what it is to the person using the app, not by the component that draws it (The same kind, the same size).
Spacing
- Use the 4px steps for all spacing between and inside components.
- Inside small pieces (chips, the gap between a pixel and its word, tags) a half step of 2px is allowed: 6px and 10px.
- Inside a track that hugs its items, a segmented control or a toggle group, the items sit 3px from the track and 3px apart: the track's own inset, which the 4px grid doesn't divide.
- Inside a frame, siblings that can each show a fill (the buttons of a toolbar, the segments of a segmented control, the chips and buttons in a field) sit as far apart as they sit from the frame: 4px in a floating toolbar, 3px in a segmented control, 6px in a field. The toolbar for selected items holds standalone buttons instead: 4px apart with a mouse, touching by touch, where each 44px button is its own tap, with a head's air at its ends (Shape). A different gap between them would be one more distance for the eye to compare (Shape).
Timeline rhythm
A conversation is read top to bottom, so the space between its lines is what tells a reader where one turn ends and where a new part of the conversation begins. The timeline uses three distances and no others, each measured from text to text (the last line of one thing to the first line of the next), because that is the gap the eye compares:
- One step per kind of break. Within a turn is tighter than between turns, and a boundary is one step wider than both, so a date line reads as a new day and not as one more message. The steps sit on the 4px grid, each one 8px wider than the last.
- A boundary is the same on both sides. A date line sits 24px from the text above it and 24px from the sender line below it. When the space under a line was larger than the space over it, the line looked attached to the message above.
- The last message never sits on the composer. The composer is a heavy frame; at the message step it read as touching the last line. From the last line to the composer's frame is a section step, the same as from the top of the list to the first line.
- Every row carries its own insets, and a boundary takes them back. A row keeps the row inset (
timeline-row-inset, 4px) above and below its text: the reach of its hover and selected highlight. The first row of a turn adds 8px above that, a transparent border the highlight doesn't paint, so every turn starts 12px above its text (spacing-timeline-lead). A date line subtracts the inset of the row above it and the lead of the row below it from its own padding, so a row never has to know what comes next, and the distances stay right whatever sits on either side. - The edge the messages scroll under fades. Wherever content scrolls under an edge, the edge fades instead of cutting it (Edges fade). The list's bottom edge, over the composer, fades from the panel's color to transparent over the section step, 24px, at all times (
MessageListEndFade, MessageList): a message scrolled under it softens, and at the end of the list it lies over the empty end and shows nothing. The line of who is about to post sits on the same fade and has none of its own. - A line that floats over the end of the list doesn't move it. The line of who is working or about to post adds its own height to the end of the list while it shows, so the last message stays whole above it (Working agents); Back to bottom shows only while the end is out of view, so it never covers the last message.
- Products don't write these numbers. Components read the timeline tokens; a product that builds its own list top or end uses only
pt-timeline-startabove the first row (the section step less the lead every row brings, the history notice included) andpb-timeline-end(the section step less the last row's inset) under the last row.timeline-turnandtimeline-leadare for the components; adding them up in a product is how the old gaps drifted.
Edges fade
Where content is cut, by a fold, by the edge of a strip that scrolls or by a column narrower than its content, its edge fades out instead of stopping on a hard line, so the cut reads as "there is more" and not as a clipped line. A fade has two lengths and no others:
- A fade is a mask, never a color gradient. The utilities fade the content itself (
mask-image), so whatever lies behind it, a row's hover or located fill, a card, a tint, shows through the fade unchanged. A gradient from the surface's color to transparent only matches one background, and bands over every other. - A fade shows the cut box's own color, never what lies behind it. A clipped column fades into the column's own color, the fill it lays under its content: the mask goes on the content inside the column, never on the column, so nothing behind the column (the window, the next column) shows through. (artin and Lagoon, 2026-11-19, mobile #5016, #proj-raft-ui:#270)
- A web view or a preview that fills its section is cut, never faded. An Artifact, an App or a file preview, and an image or a video previewed on its own, stop on a hard line at the cut: their own edge already reads as cut, and a fade over them only lays a band of the surface across them, a glow on dark media. They are the layer the column masks, so they opt out of the mask. Images and videos inside content (a message, a list) are part of that content and fade with the text around them into the column's color, and so does an Artifact drawn as text (Markdown), which is not a web view. (artin and Lagoon, 2026-11-19, mobile #5016, #proj-raft-ui:#270)
- A column cut by the screen's end edge is cut, never faded. A clipped column fades where it gives way to the next column; the last column in the row, against the window's end edge, stops on a hard line there, text and lists too. The screen's edge is itself an edge the reader sees, so the cut already reads as cut; a fade there only dims the content. (artin and Lagoon, 2026-11-19, #proj-mobile:63e3c4b4)
mask-fade-xfades only the side that hides something. It readsdata-overflowon the same element,start,endorboth, and draws no mask without it, so a strip that fits has no fade. The component that scrolls sets the attribute withuseOverflowEdges(Tabs does); never measure the overflow again in an app, nor write the fade as an inline gradient.- Put the mask on the box that is cut.
mask-fade-bgoes on the element with the fold'smax-heightandoverflow-clip, not on a layer laid over it. - One exception: the end of a message list fades with
MessageListEndFade, a layer of the panel's color over the list's bottom edge (Timeline rhythm). It lies beside the scrolling list, on the panel's own color, under the jump controls, and a mask on the list's viewport would fade its scrollbar too.
Hit targets
- Make every touch target at least 44px in both directions.
- Extend a control that looks smaller than 44px, and a text button, with a transparent pseudo-element to 44px.
- Don't extend inline links and reference chips in running text: they follow the line of text.
- The rows of a popup list are the one exception: an option of a Select, a Combobox or a ComboboxSelect, an item of a DropdownMenu or a ContextMenu, and a row of the server tab's popover on a phone (MobileNav) are 36px with one line on a touch screen and 34px with a mouse, the desktop row height (Forms). They touch each other edge to edge, so their hit area can't reach past the row to 44px. They stay that short because:
- Each row spans the whole width of the popup, so a tap a few pixels off still lands on a row.
- A tap on the wrong row only moves the highlight or chooses the neighbor, which people see and can change. It never does anything that can't be put back: a menu item that deletes, stops or removes something opens a confirmation first (Feedback). Keep such an item apart from the others, after a separator.
- Rows of 36px (34px on a desktop) keep more of the list in view.
- Desktop controls used only with a pointer may be smaller. A desktop has one row height, 34px (
row-height): sidebar rows 2px apart, their state shape as tall as the row (Lists), menu options and compact task and file rows. Rail items are 36px, the floating toolbars (the message hover toolbar, the text-selection toolbar) 42px high with buttons at the control height, 34px, 4px inside (Button), and an icon button in a bar 28px (bar-button-size: a head's actions and its ×, the composer's icons), the size of the header's icon tile, so a head's tile and buttons share one size and one centre line. Their hit area still reaches 44px. - A row's actions are 28px with every pointer: an icon-only action on a line of a row or a card, such as a comment header's More or a list row's trailing action, is a Button at
icon-sm(row-action-size), the bar button's size with a mouse. It stays 28px on a touch screen too, since a 44px or 32px box would push a line of text apart, and its hit area reaches 44px with a transparent::after(Button). A line has at most one, at its end: its target reaches 8px past each side, so a second row action beside it would overlap, and goes in its More (⋮) instead. - On a desktop, a default control is 34px, read with a pointer from further away, and it is the one desktop size of a field, a select, a Button, a tab, a selected segment, a menu or popover option, a sidebar row, a compact list row and a floating toolbar's buttons, so they line up wherever they meet (stdrc, 2026-11-04; Feishu's 32px before). A desktop here is a screen from 768px (where the desktop layout begins) whose main pointer is a mouse or a trackpad,
(width >= 48rem) and (pointer: fine): density follows the input, not the width. A tablet used by touch keeps the phone's 44px controls and 16px field text, which also keeps iOS and iPadOS from zooming into a field on focus; an iPad with a trackpad reports a fine pointer and gets the desktop sizes. A button at 34px still overhangs to a 44px hit area (after:-inset-y-control-hit, plus its 1.5px border, because an overhanging::afteris measured from inside the border), because a laptop can have a touch screen too; a field doesn't, since it is wide and its height is the target. A field in a toolbar row is the exception by touch, where it is 32px: its input reaches 44px like a button's hit area (Heights).
The same kind, the same size
Someone moving between an app's tabs compares what they see. Two lists that look like the same kind of thing but are sized differently read as a mistake, whatever each one's reason was. So within one app, elements of the same kind on the screens someone reaches from the tab bar or the rail are the same size: the same height, type size and icon size. Which kind an element is follows what it stands for, not where it appears or which component draws it (Rows).
- In Raft Chat several phone lists are one kind, a list of places, drawn with one row (Raft Chat): change one and you change them all.
- The rule holds within one app, not across them. Another app with different interaction may size the same component differently: an app built around its settings can give a settings row more room than Raft Chat does. A size belongs to the app's context; a component's doc gives the size it has where the app uses it.
- So the heights below are what Raft Chat uses today. Before changing one, find every screen in the app that shows the same kind of element and change them together.
- Pin a shared size with a test that compares the screens, not with a fixed number.
Heights
- A field in a toolbar or a filter row takes the row's button height (InputGroup
size="md"): 32px on a phone and a touch screen, like themdbuttons and filter triggers beside it. Every touch control keeps a 44px tap area; anmdfield keeps it with its input, which takes taps 6px past the box above and below, so keep at least 6px between it and the controls above and below it, as with a Button atmd. A PickerTriggerButton and a segment of a SegmentedControl keep theirs as a Button atmddoes, with a transparent::after6px past the box above and below. A segment's reaches up and down only, 3px past its track, because the segments sit 3px apart and their tap areas must not overlap. With a mouse they are the control height, 34px, and take no taps past the box. A field on its own, in a form or a dialog, keeps the control height. On a tablet held landscape, a 44px search field next to 32px filter triggers and a view switch read taller and heavier than everything else in Raft Artifacts' filter row (xxchan, 2026-11-06, #proj-workspace:68999338): a row is read as one line of controls, so they share one height, and the tap area, not the drawing, is what keeps the field easy to hit (Hit targets). Its text stays 16px, so iOS still doesn't zoom into it on focus. - Make a phone's toolbar line 49px, not a header's 56px. It is a row of controls, not a header: 32px controls with 8px above and below make a 48px row to touch, as Material's chip rows are 48dp. And a phone's toolbar often takes two lines, 89px rather than 97px, which leaves one more row of the list in view (stdrc asked Jasper to decide from research, #proj-raft-ui:f9756e85, 2026-11-10; it was a header, 57px with its seam, before).
- Size a default control with the control tokens (
h-control,size-control,size-control-iconfor its icon), never with a breakpoint of its own: they switch once, in the token layer. A metric that follows the control and has no token, such as its padding or the margin that puts its glyph on an edge, switches on the same query,md:pointer-fine:, never onmd:alone:md:would give a touch screen from 768px the desktop's 34px.
- The rail has its own width (
rail-width), not the header's: 49px with a 1px seam and 36px items on a desktop, 57px with 40px items on a touch screen. It shows icons only: a labeled rail needs 68px to fit names such as Computers. Under the top bar the rail has no head; without it, the rail header is as tall as every other header. - A wide touch screen's head is 48px, not the phone's 56px. From 768px by touch (744pt in the apps, where their wide layout begins) a head is the 36px bar button, the frame item's size, with the header air above and below: 36 + 2 × 6 = 48, the rail's head and every column's seam with it. A wide touch screen has room for more of the content, not for taller heads, and a 44px button with 2px above and below would crowd the head; the button still takes taps to 44px. A phone held upright keeps 56px, and a mouse 44px (artin, #wg-mobile-sync:#265; mobile #5576 and #5583, Raft 1.29). This follows the width and the input, not the window's height: the 600px threshold below is unchanged.
- When the desktop window is shorter than 600px (
@media (max-height: 600px)), every header shrinks together, to 40px on a desktop (a 28px bar button with 6px above and below,header-height-short) and to 48px on a touch screen. The rail is already 49px wide with 36px items on a desktop; on a touch screen it shrinks to that size; see Responsive layout. One row keeps 44px there: a line of a list's toolbar (TasksPanelToolbar) holds a 40px segmented track and its seam, which don't fit in 40, so it stays at the desktop header height.
The size chain
The sizes that follow the control are written as one chain in the token layer, so a change to one step moves every size built on it, and each step changes in one place:
- Air (
control-air, 6px): between a label, its control and its help, and around a control in a bar. - Header (
header-height): the control height plus the header air (header-air) above and below; by touch from 768px, the bar button plus the header air (48px). Every header reads it: a panel, sidebar, thread or rail head, a dialog's bar, a drawer's head, and with a mouse a line of a list's toolbar. In a window shorter than 600px,header-height-short. - Bar button (
bar-button-size,bar-button-radius,bar-icon-size): an icon button in a bar, a head's actions and its ×: 44px with a 22px icon on a phone, 36px with a 20px icon by touch from 768px (as the apps draw it, Raft 1.29), 28px with an 18px icon on a desktop. The composer's icons take it only with a mouse; by touch they are the 32pxicon-md. Its hit area reaches 44px whatever its size. - Row action (
row-action-size): an icon-only action on a line of a row or a card (Buttonicon-sm), 28px with every pointer, written as the bar button's size on a desktop so the two stay one size with a mouse. - Frame item (
frame-item-height): the top bar's and the title bar's buttons, the workspace button and the search box. - Corner (
control-radius): a control at the control height, about a quarter of it: 10px at 44 on a phone and a touch screen, 8px at 34 with a mouse on a desktop. - Switch (
switch-width,switch-height): the track; the knob is the height less 8px and travels the width less the height. - Rows (
row-height,option-height): a sidebar row from 768px, and an option of a popup list or a menu item. - Forms (
field-gap,section-gap,settings-row-inset,page-inset,page-top): two airs between fields and around a settings row's tallest part, the gap between two form sections, the inset of a column's content and a drawer's body (16px at both densities), and the space from a head's seam to the first thing under it: the page inset on a phone and a touch screen, 12px with a mouse, so the content sits close under its compact head (stdrc, 2026-11-05). - Rail (
rail-width,rail-item;rail-width-short,rail-item-short): the rail has its own size; it no longer follows the header. The short window's rail, 49px with its seam and 36px items, is also the rail a desktop with a mouse always has. - Insets and axes (
--surface-inset,--sidebar-glyph-axis,--sidebar-text-axis): CSS variables instyles.css, next to--column-margin, not tokens.--surface-insetis a surface's own padding (a dialog, a drawer, a panel section): 20px on a touch screen, the valuepx-5gave it, and the page inset (16px) with a mouse; as one variable, a caller'spx-0still replaces it.--sidebar-glyph-axis(the page inset, 16px) and--sidebar-text-axis(24px further, 40px) are where the sidebar's glyphs and text start with a mouse (Sidebar).
A component reads these tokens and never writes the number.
The chain switches at the root (:root and .light, under the desktop query). A subtree that sets its own --control-height changes that control only: the header, the bar buttons and the other steps were already worked out at the root, so they don't follow it.
Avatar sizes
Avatars come in 19px, 27px, 35px, 51px and 99px: a multiple of 8 plus two 1.5px edges. See Avatar.
Layout widths
How things land on these margins is in Alignment. Breakpoints are in Responsive layout.
Resizing columns
On a desktop every column with a range above can be dragged on its seam, within that range; two stacked side sections are dragged on the seam between them. In a conversation's row every seam trades width between its two neighbours, and past 160px goes on taking from the next column further out (stdrc, 2026-11-03, #proj-raft-ui:#189; The channel's side columns). The comment margin keeps its 280px, because the cards are laid out against it (Resizable). The ranges come from what each column holds: the sidebar's names, counts and marks start to crowd under 200px and gain nothing past 400px; a results row keeps two or three words of a thread's title at 320px and only shows more of a one-line preview past 640px.
A panel on the right of the main area (a thread, a profile or task side panel, a column of a conversation's row) has no width of its own at which it stops. What it holds, a conversation or a task, reads better the wider it is, and a fixed maximum (640px, 720px) stopped it at about half of a 1280px to 1440px window, though people wanted it to take three quarters while they worked in it (2026-10-23). In a conversation's row it grows until every column on its other side is down to 160px, their content clipped; the conversation is a column like the others there, so a drag takes it to 160px too (stdrc, 2026-11-03). Elsewhere it grows until the area left of it is down to that area's 360px minimum, the same minimum the main area keeps when the window narrows.
- Remember each width in each browser, not per server or account, except a channel's side sections: where each section stands and the width of each column without the Thread are kept for the person in each server, so they follow them to another browser. The thread's column keeps the thread panel's width, and the conversation's width, once a seam beside it has been dragged, is kept in each browser too. The sidebar is one width on every page that has one, so it doesn't jump when people move between Chat, Members and Settings. The profile panel and the task side panel share one width too.
- When the window is too narrow for the remembered widths of a conversation's row, the columns give way in the row's order: above their content's minimums first, then the thread folds over the conversation, then they clip down to 160px, then the rightmost become tabs (The channel's side columns). Elsewhere, draw the columns narrower, starting with the rightmost, down to their minimums, and keep the main area at least 360px; a side panel that still doesn't fit covers the main area (Responsive layout). The remembered widths don't change, so a wider window brings them back. The sidebar keeps its width for a conversation's row: it is not one of the row's columns, and collapsing or opening it changes the row's room as the window does. A sidebar that gave way would jump each time the thread opens or folds. Elsewhere, a column left of the main area narrows for a side panel only while that still puts the panel beside the main area; when it can't, the column keeps its width and the panel covers the main area.
- Draw a remembered width outside a column's range at the nearest end of the range; don't reset it, so a change to a range doesn't throw away a person's choice.
Related
- Page structure: how the regions are arranged.
- Shape: radii and stroke widths.
- Visual comfort: how spacing, insets, lines and surfaces work together.