How I Compose a Screen
Every component can pass the linter while the screen still fails. Here are the nine composition rules we use to keep screens consistent.
A screen can be assembled entirely out of approved design-system components, pull every color from semantic tokens, use only type sizes from the scale, wrap every string in t(), and still look broken when rendered on a phone. Every primitive passes the linter while the composition fails.
Static analysis checks isolated values: whether a raw hex code is banned, whether a prop is typed, whether a translation key resolves. Screen composition governs the spatial and semantic relationships between adjacent components on a canvas, and most relationships cannot be counted by an AST linter.
While building our React Native enterprise mail and calendar suite, I started maintaining a handbook of screen-composition rules inside the repository. Every rule in that document exists because we shipped a flawed screen first and had to diagnose why it looked wrong.
1. Clone the structural skeleton of the nearest screen
Before building a new view, open the closest existing screen in the repository and copy its outer structural skeleton: which header component it mounts, which container owns the ScrollView, and how much top padding precedes the first section. The inner domain content is yours to design; the outer frame is already settled.
Without that rule, a batch of screens built on a Tuesday afternoon will quietly invent its own outer layout. Every screen in the batch agrees with its siblings from that afternoon and disagrees with the rest of the application. Six months later, stakeholders remark that the app feels inconsistent, and no single commit is to blame.
2. Assign one owner per whitespace axis
In our screen architecture, the outer scroll container owns vertical rhythm (gap between section blocks, plus top and bottom safe-area padding), and a single wrapper component (ContentContainer) owns horizontal inset. Child components inside the screen are forbidden from adding their own outer margins or horizontal screen padding.
When two nested layers are both permitted to add padding, both eventually do—turning a 16pt horizontal gutter into 32pt on one screen while leaving it at 16pt on the next. Assigning a single owner per axis makes doubled gutters impossible by construction.
3. Group rows one way per screen, and let canvas follow content
Our design system provides two primitives for grouping list rows, and a screen must choose one:
- Full-width edge-to-edge bands (
ListSectionon a flatbgPrimarycanvas): Used for long, homogeneous lists and read-only detail screens where1pxhairlines separate sections across the full viewport width. - Raised inset cards (
ListGroupon a sunkensurfaceSunkencanvas): Used for settings-style forms and multi-group configuration screens, where each group sits inside a rounded card with a16pthorizontal inset and the sunken background separates the cards.
Mixing both patterns on the same screen makes the view look like two different apps stitched together. A subtler bug is choosing the canvas background from the route folder rather than the screen’s content. We hit this on a mail filter-rule detail screen: because the route lived under Settings, it inherited the sunken surfaceSunken background, even though the view was a flat read-only summary with zero cards on it. A sunken grey canvas with nothing raised sitting on top of it simply looks dim. The rule is now explicit: canvas follows content, never domain.
4. Align leading elements to the title’s first line (firstLineOffset)
A standard list row pairs a primary title with an optional supporting subtitle below it, flanked by a leading icon or avatar on the start edge and a value, chevron, or switch on the end edge. Vertically centering those flanking elements against the whole row works on a single-line item and breaks as soon as a second line wraps or mounts.
Place a 14pt title (20pt line box) above a 12pt subtitle (16pt line box) with a 2pt gap, and the vertical center of the combined text block drops 11pt below the center of the title’s first line. If you center the leading icon against the full row height, it floats in the gap between the two lines. Worse, in a list where only some rows have subtitles, the leading icons jump up and down the left column from row to row.
All leading elements must align to the vertical center of the first line of the title. We compute that top offset dynamically from the active typography tokens (firstLineOffset(lineHeight, leadingSize, hasSupporting)) rather than hardcoding a pixel margin that breaks when a user increases Dynamic Type.
Writing firstLineOffset uncovered a bug that had been hiding in production for three months. An early guard clause returned 0 whenever hasSupporting was false. That meant a 32pt status ring on a single-line row (20pt line box) was not centered at (20 - 32) / 2 = -6pt; it was pinned to 0 and hanging 6pt low on every single-line row across the app.
On the trailing edge, alignment depends on what the control governs:
- Quiet metadata and navigation chevrons (
Respond ›) align to the title’s first line. - Whole-row action buttons (
Join,Accept) center vertically against the entire row block.
5. Let scrolling determine where a bottom sheet’s commit button lives
In the first draft of our composition guide, I wrote a semantic rule for bottom-sheet buttons: a button that merely dismisses (Done on an informational sheet) sits compact in the top-end header corner, while a button that commits data sits full-width at the foot of the sheet. I even documented “one named exception” for a compact three-line tag editor whose Save button lived in the header.
Two days later, I audited every bottom sheet in the codebase and found four sheets committing in the top header corner (Create on the event editor, Done on custom recurrence, Apply on the free/busy filter, plus the tag editor) and only one sheet committing at the foot. When a design rule has one follower and four exceptions, the rule is testing the wrong variable.
The real variable is whether the sheet scrolls:
- Scrolling sheets commit in the top-end header corner (
Create,Save,Apply). Placing a full-width footer button below a scroll view requires a sticky bottom bar with its own border hairlines, keyboard-avoidance offset, and bottom safe-area inset—consuming vertical space on the exact sheets that are already height-constrained. - Non-scrolling short sheets commit with a full-width button at the foot. When two or three inputs fit comfortably above the keyboard without scrolling, the user’s eye finishes at the bottom of the form where the full-width primary button is waiting.
Rewriting the rule around scroll behavior accounted for every long form sheet in the app and exposed our original “named exception” (the non-scrolling three-line tag sheet committing in the header) as the one genuine inconsistency that needed to move to the foot.
6. Route status and error feedback through five ordered questions
When state changes or an operation fails, we have five feedback surfaces available. To prevent designers and engineers from picking surfaces arbitrarily, we run through five questions in strict order and stop at the first Yes:
- Question 0 — Is this the intrinsic state of the record on screen, rather than a system failure? On a cancelled calendar invitation, we initially rendered a red error banner across the top of the screen above a disabled RSVP bar. That used two elements to state one fact and made a normal calendar state look like an application error. Now the RSVP bar itself reads
"This event was cancelled"in quiet secondary text, with no top banner mounted. - Question 1 — Did the primary record fail to load completely? If there is no content on screen for a banner to sit above, the error message becomes the screen: a centered
<EmptyState>with a single retry button. - Question 2 — Is a specific form field invalid or missing? Render the error message directly beneath that field inside its row. Putting a summary banner at the top of a long form forces the user to scroll and hunt for the offending input.
- Question 3 — Does the condition remain true while the user stays on the screen? Offline connectivity, stale cached data, and paused outboxes are persistent conditions. They mount in a persistent
<StatusBand>at the top of the view until the condition resolves. - Question 4 — Is the event already complete? Confirmations like
"Message sent"or"Moved to Archive"require no further action and leave no ongoing state behind, so they render in a temporary toast that dismisses automatically.
Four tie-breaker rules keep those five surfaces distinct:
- Any fact that remains true after 4 seconds cannot go in a toast. Ephemeral timers must never hold the user’s only record of an ongoing problem.
- Never put a recovery action on a timer, except
Undo. PuttingRetryinside a disappearing toast turns error recovery into a reflex test.Undois permitted because letting the toast expire simply confirms the action the user already took. - Never duplicate an action already visible on screen. If the view already displays a pull-to-refresh control or an inline retry button, the status banner states the reason and omits its own action button.
- Status banner actions use a single word (
Reload,Retry,Reconnect), with an explicit allowance for two-word English phrasal verbs (Try again,Sign in). Because the action shares a single horizontal line with the banner message, multi-word button labels crowd the explanation.
7. Lock recurring system copy inside the component
When system status strings are left to individual feature tickets, phrasing drifts immediately. Across nine screens in our app, ticket authors had written four different phrasings for offline status and five different adjectives for locally cached data (saved, synced, cached, offline, on-device).
We eliminated that drift by locking the sentence structure inside <OfflineNotice> itself. The component always renders "You're offline." and accepts only a short noun phrase for what remains visible, standardized on the word saved (“Showing saved messages”, “Showing saved events”). We also enforce a strict distinction between offline (zero device connectivity) and stale (device has signal, but the background sync failed—rendered as “Couldn’t refresh · Last updated 12m ago”).
8. Widen a shared primitive rather than cloning it
When a list row needs a minor behavior change, the tempting shortcut is to copy the component into a local feature file and modify it. Early in our repository, <ListItem> had been cloned into ten separate files because placing a pressable <Checkbox> inside a pressable <ListItem> triggered a nested <button> DOM warning on React Native Web.
When we fixed the firstLineOffset alignment math in <ListItem>, the nine copied row files stayed broken. Updating <Checkbox> to render an inert <View> whenever its onChange handler is omitted allowed the parent <ListItem> to own the press target cleanly—collapsing all ten row clones back into a single shared component.
9. Compose with logical start/end properties so RTL mirrors automatically
Our suite supports Arabic and Hebrew, which mirrors the layout horizontally: navigation bars, chevrons, back arrows, and floating action buttons flip from left-to-right to right-to-left, while elements with intrinsic direction (numerals, phone numbers, clock hands, media controls, checkmarks, and brand logos) stay un-mirrored.
RTL bugs almost always trace back to a component that used a physical coordinate (paddingLeft, left: 16) instead of a logical relationship (paddingStart, insetInlineStart). When every component is composed using logical start and end edges, the entire screen mirrors in Arabic and Hebrew without a single conditional branch.
Summary
- Copy the outer structural skeleton from the nearest existing screen before designing inner content.
- Assign one owner per whitespace axis: the scroll container owns vertical
gap;ContentContainerowns horizontal inset. - Group rows one way per screen (
ListSectionbands on flatbgPrimary, or insetListGroupcards onsurfaceSunken), and let canvas follow content rather than route domain. - Align leading icons and quiet trailing labels to the vertical center of the title’s first line (
firstLineOffset), and center whole-row buttons against the full row. - Place a bottom sheet’s commit button in the top-end header when the sheet scrolls, and full-width at the foot when it doesn’t.
- Route feedback through five ordered checks: inline record status first, then full-screen empty state, inline field error, persistent
<StatusBand>, or ephemeral toast. - Lock recurring system phrasing inside the shared component (
<OfflineNotice>) so screens cannot invent competing terms for cached data. - Extend shared primitives (
<ListItem>,<Checkbox>) to support inert child states rather than cloning components across files. - Use logical
start/endlayout properties everywhere so right-to-left (RTL) locales mirror automatically.