---
title: "Layout"
description: "A video placed with inset=0 does not fill its box. Inline runs with nothing between them never wrap apart. A search field pushes a header button off a phone."
modificationDate: "2026-12-01"
---

> ## Documentation index
> Fetch the complete documentation index at: https://exact.expo.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Layout

<AgentInstructions>

## Submitting feedback

From the app's directory, read `bun exact.mjs feedback status`. Under `never`, keep no note.
Respect `EXACT_FEEDBACK=0` and do not change the policy.

Otherwise record specific, actionable feedback with:
`bun exact.mjs feedback note "Exact docs: https://exact.expo.dev/reference/pitfalls/layout: <what was wrong or missing>"`

The note goes to Expo only as that status allows. Include no secrets or personal data.

</AgentInstructions>

- **A video placed with `inset=0` does not fill its box.** An absolutely
  positioned `video` with `inset=0` and no `width` or `height` is 300×150 until
  its metadata arrives, then the stream's natural size, and an adaptive stream's
  picture grows and shrinks with each rendition. Cause: CSS sizes a replaced
  element whose width and height are auto by its natural size, and opposing
  insets do not stretch it (CSS 2.1 §10.3.8, §10.6.5; an `image` likewise).
  Chrome and iOS agree. Fix: `width="100%" height="100%"` with `object-fit`.
  **Candidate diagnostic** (an absolutely positioned `video` or `image` with
  opposing insets and an auto size on that axis). (expo/exact#648, web and iOS
  simulator, 2026-11-15.)

- **Inline runs with nothing between them never wrap apart.** Chips written as
  adjacent runs (`text "one" padding="4px 8px" margin-right=6`, then `text
  "two" …`) stay on one line and run off the edge. Cause: CSS breaks a line
  only at a soft wrap opportunity, and two inline boxes with no white space
  between them have none (CSS Text 3 §5), so the runs are one word; the web
  does the same, and the margins still apply. Fix: a `text " "` run between
  each pair. (expo/exact#649, web and iOS simulator, 2026-11-15.)

- **A search field pushes a header button off a phone.** Under `--chrome agent`,
  the authored header lays out in the page. A search field with no width constraint
  can keep its intrinsic width even when the heading has `flex=1`. Give the field
  `flex=1 min-width=0` so it takes the space left by the heading and buttons.
  (Agents, 402-point iOS simulator, 2026-11-12.)

- **Safari drops a declaration that names a viewport segment, its fallback included.** Safari on
  iOS 27.1 parses no `env()` with indices, so `width="env(viewport-segment-width 1 0, 100%)"` leaves
  the width `auto`. Nor does it tell a page about the hinge: on an iPhone Duo the posture, the
  segments and the window's size are the same at 180° and 90°. Fix: write a segment only where `exactViewport()`
  reports two, as the [foldables recipe](https://exact.expo.dev/recipes/foldables.md) does. (A page in Safari on an iPhone
  Duo simulator, 2026-11-24.)
- **A layout-region inset is not a page gutter.** The web can report zero
  for `env(-exact-readable-content-corners-inset-left)` and its right-edge equivalent. Give reading
  content ordinary padding inside the safe region, and bound a full-width
  field with `box-sizing="border-box"`: its native padding and border otherwise
  extend beyond the authored width. (Duo Lab, 2026-11-04.)

- **`gap`, `row-gap` and `column-gap` accept numeric lengths, not `calc()` or `env()`.**
  The compiler rejects a segment-based gap with `lower-attr-value: expected
  nonnegative number`. Place the panes either side of the hinge by segment edges, in a
  container aligned with the viewport. Global segment lengths used as flex bases shrink across
  the hinge if a header or footer reduces the container's space. Put that chrome
  inside a pane, and end a bottom pane at `bottom: 0`. For side-by-side
  panes, automatic left/right insets with flex start/end alignment preserve
  reading order; fixed width plus both physical insets overconstrains RTL.
  Keep the same pane instances while their positions change. (Duo Lab, 2026-11-05.)

- **In the web build, a view that leaves with an exit animation can jump as it starts
  to fade.** Symptom: the leaving view starts its exit higher or lower than it was,
  when the same action also changes its parent's layout, such as a top padding that is
  there only while the view shows. iOS and macOS keep it in place. Cause: the web
  build (the JS target) reads a leaving view's box during its page update, after it
  has already applied the action's other changes; iOS and macOS read it before any
  change (LLP 1063, "Known gaps"). What to
  do: give the space to the leaving view instead of its parent, for example a
  `margin-top` on a banner in place of a column's `padding-top` that follows whether a
  banner shows, so the action that removes the view does not also change its
  parent's layout. (A vehicle app's offline banner, 2026-10-30.)

- **An unknown-size image stays blank after disclosure.** On Windows, an auto-height
  wrapper around a percentage-width image can leave the image at zero height before
  decoding. The lazy loader then sees no visible area to load. Give the image a fallback
  ratio, such as `aspect-ratio="auto 16 / 9"`: it reserves space until the image's
  natural ratio arrives. (Excord image spoilers, 2026-10-24.)

- **`link "Title" href="/item"` is refused as zero-sized.** Only a `button`'s
  positional title becomes a text child; a `link` needs explicit children. Write:

  ```contract
  link href="/item"
    text "Title"
  ```

  (Web split metadata fixtures, `lower-zero-size`, 2026-10-14.)

- **A computed px `width` beside text in a role does not grow with Dynamic Type.** The
  compiler warns `lower-text-px-width` of a literal px width around text that scales with
  the person's text size; of a computed one (`width=(narrow ? 48 : 60)`) it says nothing,
  and at accessibility sizes the text runs past it. Fix: the width in `rem`
  (`width="3rem"`), a grid of `auto` tracks, or `flex-wrap="wrap"` on the row. (Bake-off
  round 13, weather; LLP 1116.011 D2.4.)

- **A border on one cell of a grid of `flex=1` cells pushes its column out of line.**
  A border adds to a box's outer size (CSS's `content-box`, and `border-box` too: a
  `flex-basis` of 0 is never smaller than the border), so a calendar's today with
  `border-width=(isToday ? 2 : 0)` is wider and taller than its neighbours and
  the days after it sit off the columns above. Fix: give every cell the border and vary
  its colour, `border="2px solid" border-color=(isToday ? "-exact-label" : "transparent")`.
  (Bake-off round 28, mood journal: 50.9 points against 47.4 on iOS; Chrome alike, with
  `border-box` too.)

- **A column with `width="100%"` inside a dialog stays narrow in an iOS sheet.**
  The dialog has `fit-content` width, as in HTML, so the child's percentage resolves
  against that dialog's width. Put `width="100%" box-sizing="border-box"` on
  the `dialog` itself to fill the sheet between its side insets. Verified on an
  iPhone 17 Pro simulator, iOS 27.0 (#845).

- **An `alertdialog` button with `press=action` and `commandfor`/`command="close"` stays open when `action` disables it.**
  Symptom: tapping Save clears the prompt input (`draft = ""`), `disabled=(draft == "")` turns
  true, and the alert never closes. Cause: HTML runs the button's click handler before its
  invoker command and skips `command="close"` when the button is now disabled, and Exact's
  native hosts follow HTML (LLP 1115). Fix: call `close("id")` inside the action (without
  `commandfor`/`command="close"`), or clear `draft` in the mutation's `then` or the dialog's
  `close` handler. (Feedback `b39da82a`, web and native hosts, 2026-11-19.)

- **A root with `min-height="100%"` and `overflow-y="auto"` does not scroll itself.**
  `min-height` lets the box grow with its in-flow content (CSS), so it has nothing to
  scroll and the document scrolls instead: on the web a screenshot shows only the first
  screen, and on iOS a builder found the results stuck below the keyboard (a finger can
  be caught by the root's own scroll view, which has no range). Fix: `height="100%"`
  with `overflow-y="auto"`, or a `column height="100%"` holding a `scroll` with `flex=1
  min-height=0`. (Authoring bench, LLP 1087, r33 t1-tip and ios25 t1-tip, 2026-10-06.)

- **A checkbox, a radio or a range touches the text beside it.** Cause: a control
  has no margin of its own on any host (LLP 1115.000 D10.1): the few pixels a
  browser's own sheet puts around them are reset, as every common reset does, so
  the page and the native control are laid out alike. Fix: `gap` on the row
  (`row align-items="center" gap=8`), which a grouped `list`'s rows already have.
  (Wave 2 of LLP 1115.000, a scratch page on the web, the Mac and iOS, 2026-10-11.)

- **Padding on a checkbox or switch does not add space.** Cause: Chrome ignores
  padding on a checkbox or switch with native appearance, and Exact matches it
  under the default `appearance="auto"`. Fix: use `margin` or a padded wrapper
  for spacing while keeping the native face. `appearance="none"` preserves
  authored padding but opts out of that face. Reproduced in the kernel's
  [form-control tests](https://github.com/expo/exact/blob/41ded8c5ede0b2959ef0daa83b1ff78545dd4428/kernel/tests/it/browser_controls.rs), 2026-10-17.

- **A label beside a `range` or a `progress value=` wraps onto two lines, and the
  control is wide.** Cause: both are `width: 100%` unless you say otherwise (LLP
  1115.000 D10.2), and in a `row` that is the control's flex basis: the row
  overflows by the label's width and CSS shrinks both children, the label down
  to its longest word ("Screen brightness", 164 points, became 116 beside a
  range in a 400-point row). Fix: `flex=1 min-width=0` on the control, which
  then takes what the label leaves; or a `width`. In a `column` or a plain box
  nothing is needed. **Candidate diagnostic:** a `range` or a determinate
  `progress` with no `width` or `flex` beside a `text` in a `row`. (Wave 2 of
  LLP 1115.000, Chrome 154 and the kernel alike, 2026-10-11.)

- **A `\n` in a text runs its two lines together.** ``text `${ref}\nResults rounded.` ``
  showed one line on the web and in an iOS grouped footer. Cause: `white-space:
  normal` (CSS's default) collapses a line feed to a space, as a `<div>` does. Fix:
  `white-space="pre-line"` on the text, which every host then draws as two lines
  (a grouped list's footer and cells included), or two `text`s. **Candidate
  diagnostic:** a literal `\n` in a text whose `white-space` collapses it.
  (Bake-off round 6, unit-converter; LLP 1116.004 D2, 2026-10-11.)

- **A `text` with `line-height` whose child runs all change the font can be taller than its
  runs.** A code line with `line-height=1.5714` whose child runs set a 14 pt monospace
  font measured 23 pt high on iOS instead of 22 pt beside a line-number column. Cause:
  CSS's line-box strut comes from the block `text`'s own font (the inherited 17 pt body
  font) and keeps every line box at least as tall as that strut (CSS Inline 3 §3). Fix:
  set the same `font-family` and `font-size` on the parent `text` itself, not only on its
  child runs. (expo/exact#1937, iOS, 2026-11-26.)

- **Code blocks rendered as one `text` per line copy with blank lines between lines.**
  Cause: each `text` is a separate paragraph block, so multi-paragraph copy joins separate
  `text` blocks with `\n\n` on macOS and iOS (matching HTML `<p>` copy semantics). Fix:
  put a code block's lines in one `text` with `white-space="pre"` (using inline runs for
  syntax highlighting) so line breaks inside the block copy as single `\n`.
  (expo/exact#1937, iOS and macOS, 2026-11-26.)

- **A ported `clamp(inset, 15, 60)` never stops at 60.** Cause: React Native
  code's `clamp(value, min, max)` (lodash's order) is not CSS's `clamp(MIN, VAL,
  MAX)`, which is `max(MIN, min(VAL, MAX))`: `clamp(env(safe-area-inset-bottom),
  15px, 60px)` is the inset whenever it passes 15. Fix: `clamp(15px,
  env(safe-area-inset-bottom), 60px)`. (Bluesky clone's bottom bar, the kernel
  test that caught it, 2026-10-07.)

- **An image tile grows to its picture's size.** An album tile in a flex row became
  900×1200 pt. Cause: a flex item's automatic minimum is its content size (CSS), and
  an image's content size is its intrinsic size. Fix: give the image or its flex
  parent `min-height=0` (`min-width=0` across a row), or position it absolutely in
  a sized box. (Signal Clone DIARY, build 7.)
- **A sheet's form does not scroll, and `tap <scroll> drag 0 -400` moves nothing.** The
  sheet's root `column flex=1` grew to its form (1315 pt), as a browser's would, and the
  `scroll flex=1` inside with it. Cause: CSS `min-height: auto` on the column. Fix:
  `min-height=0` on the column, as `lower-scroll-grows` says; `layout <scroll>` shows the
  height. A UIKit sheet sizes nothing for you here. (euxy port 14, FRICTION 9.)
- **`color-scheme="light dark"` is refused.** Contract accepts only `light` or
  `dark` to fix a subtree's scheme. Leave it unsaid to follow the surrounding
  scheme; put `color-scheme="dark"` on a media viewer itself, not its shared
  page wrapper.
- **In dark mode the navigation title and status bar turn white on a light page.**
  Cause: the app paints a fixed light background (`background-color="#FAF7F2"`)
  while the system is dark, so UIKit's bars and the platform's colours go dark
  around it. Fix: leave the background unsaid (the platform's, LLP 1115), or, for a
  deliberately light-only design, write `color-scheme="light"` on the root, which
  holds the whole app in light as `overrideUserInterfaceStyle` does. (Shelf port,
  2026-10-09.)
- **A menu opens white on a dark page.** Cause: `scheme=fixed` tokens colour the
  boxes they are written on, but the app's scheme is still the device's, so the
  platform's menus, sheets, alerts and pickers stay light. Fix: an always-dark design
  writes `color-scheme="dark"` on the root, which every host's surfaces take, or says
  `"userInterfaceStyle": "dark"` in `app.json`, which Android, Linux and Windows do not
  read; a menu in the brand's colours writes `background-color` and `color` on its
  `popover` column, which the web draws and its rows take. (#552, 2026-11-14; #1469.)

- **The app is wider than the window, and its tests still pass.** A box with
  `width="100%"` and padding is wider than its parent by the padding (`content-box`, as
  in CSS without a reset), and an `expect` never sees it. The compiler warns
  (`lower-width-padding`) when the width and the padding are literal; a computed width or
  padding, and `height="100%"` with padding, it does not. Fix: `box-sizing="border-box"`
  on the box, or drop `width`: a box in a block or a `column` already fills the width.
  On iOS the host pads a route's root clear of the iPhone Duo's side strip and of a
  split's list beside its detail (LLP 1123 D3, LLP 1127 D9), so a route's root with
  `width="100%"` runs past the screen by that much: place it with `position="absolute"
  inset=0`, as the patterns' routes are. Look at a screenshot on each host.
  (Fresh-agent README trial, 2026-10-04.)

- **A list of buttons is ragged: each is only as wide as its text.** A `button`
  directly in a `scroll` or another block container shrinks to fit, so a row's
  `flex-grow` title never grows and its trailing columns sit right after it.
  Cause: a button is a block that shrinks to fit (HTML's is `inline-block`); only a
  flex item, or one given a width, fills its line. Fix: `width="100%"` on the button,
  or put the rows in a `column`. (The LLP terminal reader's document tree, 2026-10-08.)

- **A raised `z-index` leaves a dragged card under the next column.** A card at
  `position="relative" z-index=10`, dragged over a neighbouring column, paints
  beneath it. Cause: `z-index` orders siblings, not a whole stacking context as in
  CSS (a declared deviation, LLP 1001 "`z-index`
  orders siblings"), and on the web a box that follows a positioned or stacked box
  becomes a paint group (`isolation: isolate`). A child cannot rise above its
  parent's later siblings. Fix: raise the ancestor that is a sibling of the others
  (the card's column, while it holds the dragged card), or draw the dragged card in
  an overlay at the board level. For cards between lists, a `reorderGroup` on the
  lists has the host draw the card in its top layer instead (LLP
  1094). (Authoring bench, LLP 1087,
  t4-kanban: two builders, 5 and 10 minutes, 2026-10-04.) A chess board's drag ghost
  is the same: a ghost inside the square it left stays under the squares after it;
  draw it as a later sibling of the squares, positioned in the board (chess diary #5).

- **The content of an overlay vanishes behind its own background.** Cause: a
  background box with `position="absolute"` (a dimmer, a gradient) paints
  over every later sibling that is not positioned, as CSS orders it. Before
  LLP 1083.000 the Apple hosts painted in tree order and hid this. Fix: give
  the content `position="relative"`, or give the background `z-index=-1`
  inside a parent that stacks. (Signal Clone's call screen, build 16.)

- **An overlay with `inset=0` covers the screen, not the row it is in.** A lit bar or a
  ring written as in React Native, `position="absolute" inset=0` inside a row, covers
  its nearest positioned ancestor (a route, or the screen when there is none) and
  paints over every row around it. Cause: a bare box is `position: static`, as in CSS;
  React Native makes every view a containing block. Fix: give the parent it should
  cover `position="relative"`. The compiler cannot tell this from an overlay meant to
  cover the route (a scrim, a route over the root), so nothing warns. (The euxy port's
  lane overlays and JAM ring, 2026-10-15.)

- **`flex=0` collapses a column that has a `width`.** A side column written
  `width=400 flex=0 min-width=0` in a 1,100 px row laid out 0 px wide, and the
  pane beside it covered its search field. Cause: `flex: 0` is CSS's `0 1 0%`:
  the basis is `0%`, not the width, and the item shrinks (`flex=<n>` is always
  `<n> 1 0%`; `contract vocab flex`). Fix: `flex="none"` (`0 0 auto`: the width
  is the size), or no `flex` and `flex-shrink=0`. (Stocks DIARY, about 15
  minutes; reproduced on the web and macOS, 2026-10-04.)

- **A package view with `height=44` can shrink to zero in a crowded column.**
  CSS's default `flex-shrink: 1` lets an overfull fixed-height column compress
  its children, and `min-height: auto` holds a box only at its content's size:
  a native leaf such as `exact-sign-in-button` has none, so it goes to 0, as an
  empty `<div>` does on the web. Put the content in an auto-height column
  inside a viewport-sized `scroll`, or give the leaf `flex-shrink=0`.
  (Auth Fixture's provider buttons, iOS simulator, 2026-11-12.)

- **A one-edge border draws a frame, and a drawer closed to `height=0` stays open
  a few pixels.** `border-top-width=1 border-style="solid"` on a 60 × 20 box drew a
  1 px top and 3 px sides and bottom (66 × 24); with `box-sizing="border-box"` and
  `height=0` the box was 4 px tall. Cause: `border-style` sets all four sides (CSS),
  and a side whose width is unsaid keeps CSS's initial `medium`, 3 px. Fix: say the
  one side: `border-top="1px solid"` (the side's shorthand), or
  `border-top-width=1 border-top-style="solid"`. (T3 Code clone's terminal drawer,
  whose panes lost 6 px to side borders, 2026-10-06; reproduced on the web and
  macOS, 2026-10-12.)

- **A button in a table's numeric column stays at the cell's start.** A sort button in a
  `th text-align="end"` sat at the left of its column while the numbers under it lined up
  at the right. Cause: a bare node is `display: block`, a `button` too, where HTML's
  `<button>` is `inline-block`; `text-align` places inline content, not a block. Fix:
  `margin-left="auto"` on the button, as a block's auto margin places it. (The `site`
  pattern's sortable table, LLP 1153 D8; reproduced on the web, 2026-10-30.)

- **Text stacked under a title sits higher than in a SwiftUI original.** In the
  Landmarks port on iOS, the description under a 28-point bold title started 3 points
  higher than in Apple's SwiftUI sample. Two causes, measured on the simulator. First,
  the sample's `VStack` with no `spacing` puts SwiftUI's default distance between the
  two texts, 2 points for this pair, where a Contract `column` has no `gap`: write it
  (`gap=2`). Second, 1 point remains, from the text boxes. Exact lays author text out
  in the web's line box for the system font, as Chrome's `system-ui` does
  (`CSSLineBox`: the face's ascent and descent, 1980 and 432 per 2048 units, each
  rounded to a point), so the title's box is 33 points with 6 below the baseline.
  SwiftUI sizes a `Text` frame from UIKit's font metrics (ascender 26.66, descender
  6.75, line height 33.41) and rounds it up to the device pixel: 33.67 points, about 7
  below the baseline. The glyphs sit in the same place; only the boxes differ, so text
  stacked under text sits that much higher. Exact keeps the web's line box, the layout
  model every host shares. When a port must match its original to the pixel, compare
  glyph positions on both (a screenshot's rows of ink) and add the difference under the
  title, as the React Native entry below does with `-exact-hairline`.
