---
title: "Recipe: tabs"
description: "Use tabs for at least two top-level sections, each with its own route stack."
modificationDate: "2026-11-28"
---

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

# Recipe: tabs

<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/recipes/tabs: <what was wrong or missing>"`

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

</AgentInstructions>

`bun exact.mjs pattern tabs` uses iOS's bar. [Tabs and stacks](https://exact.expo.dev/learn/contract-for-agents/tabs-and-stacks.md)

On iPhone, hide the tab bar on pushed routes so UIKit does not draw toolbar buttons under it:

```prompt Split my app into tabs
Split the Exact app in this folder into tabs, each with its own route stack. Use https://github.com/expo/exact/blob/main/docs/recipes/tabs.md as the source for each step. The Exact checkout has the same page at docs/recipes/tabs.md.

1. If this folder is not an Exact app (it has no exact.mjs and app.contract), stop and tell me.
2. Tabs need at least two top-level sections; a one-tab bar is wrong. If I did not name the sections, propose them from what the app does (its current screens become the first tab) and ask me before you write code.
3. In app.contract, make each section a `tab` in `routes`, with its own routes under it, and add a `pick` action that runs `select(nav, name)`. Draw a `tabpanel` for each tab with its stack inside, and a root `tablist` as the root column's last child: one `role="tab"` button per tab, with a symbol over a label, `aria-controls` naming its panel and `aria-selected` when it is `nav.tab`.
4. To hide the tab bar, use `display="none"`, never `if`.
5. Keep the existing tests passing without changing what they check. A test that reads inside a tab other than the first must tap that tab first.
6. Add a test in app.test.contract that opens a screen in one tab, switches tabs and back, and expects the screen to still be there.
7. Follow the platform checks in docs/start-here.md (`bun exact.mjs docs platform checks`) for the targets in the app's AGENTS.md and app.json until they pass. Read the reports, including counted findings; a zero exit code alone does not mean clean. Fix the app, not the test. The tab bar takes height from each screen, so verify may find overlaps at the largest text size: fix them in the app. If a finding stays after three rounds of fixes, or the app had it before you changed anything, record it (step 8) and report it; do not keep trying.
8. When a doc was wrong or missing, or a step needed a workaround, read `bun exact.mjs feedback status`. Under `never`, keep no note. Otherwise record it: `bun exact.mjs feedback note "<what happened>"`, which goes to Expo only as that status says. Do not change the policy; tell me how many notes you kept.
9. Tell me the tabs and what each holds, what the tests and verify reported, and the launch command for each target platform. A web window 840 px or wider draws the tab bar as a sidebar.
```

```text
row role="tablist"
  display=(top(nav).name == "day" ? "none" : "flex")
```

An app-drawn bar overlays full-height routes: pad routes by bar height plus safe inset, and label badges for VoiceOver. Unfolded, an iPhone Duo's tab bar moves to the trailing edge; add `-exact-safe-area="left right"` on full-bleed routes.

```contract
routes nav
  tab today "/"
  tab history "/history"
    day "/day/:key"

component App
  state count = 1
  action pick(name: string)
    nav = select(nav, name)
  action follow(url: string)
    nav = go(nav, url)
  view
    main viewport-fit="cover" navigationKey=`${top(nav).id}` navigate=follow
      width="100%" height="100%" position="relative"
      column position="absolute" inset=0
        for t in nav.tabs key=t.name
          column role="tabpanel" id=`panel-${t.name}` position="absolute" inset=0
            for e in t.stack key=e.id
              column navigationKey=`${e.id}` position="absolute" inset=0
                box-sizing="border-box" display="flex" flex-direction="column"
                padding-bottom="calc(49px + var(--exact-safe-area-inset-bottom))"
                header
                  text (e.name == "today" ? "Today" : e.name == "history" ? "History" : e.params.key)
                    role="heading" aria-level=(e.name == "day" ? 2 : 1)
                scroll flex=1 min-height=0
                  if e.name == "history"
                    link href=path("day", "2026-10-09") testId="day-2026-10-09"
                      text "Yesterday"
                  else
                    text (e.name == "day" ? e.params.key : "Nothing logged yet.")
      row role="tablist" appearance="none" position="absolute" left=0 right=0 bottom=0
        height="calc(49px + env(safe-area-inset-bottom))" box-sizing="border-box"
        padding-bottom="env(safe-area-inset-bottom)" background-color="-exact-background" testId="tabs"
        for t in nav.tabs key=t.name
          button role="tab" aria-controls=`panel-${t.name}` aria-selected=(nav.tab == t.name) press=pick(t.name)
            testId=`tab-${t.name}` flex=1 min-height=0 padding=0 position="relative" appearance="none"
            display="flex" flex-direction="column" align-items="center" justify-content="center"
            image (t.name == "today" ? "symbol:calendar" : "symbol:chart")
            text (t.name == "today" ? "Today" : "History")
            if t.name == "history"
              row position="absolute" top=2 right=16 aria-label=`${count}` testId="badge"
                background-color="-exact-system-red" border-radius=12
                text `${count}` font-variant-numeric="tabular-nums"
```

Tabs mount on selection and keep their stacks, drafts and scroll. Reselecting pops.
Hide with `display="none"`, drop the route padding and [gate requests](https://exact.expo.dev/learn/contract-for-agents/composition-and-lifetime.md#a-features-requests).
