Skip to content

Layout

Player 1 Inventory is a mobile-first application. The default (unstyled) layout targets small screens; responsive modifiers (lg:) layer on desktop enhancements. No custom layout tokens are defined — all layout is done through Tailwind’s default utilities.

Mobile-first approach

The app is used primarily on phones while shopping or cooking. The baseline layout is optimized for a single-column vertical flow on a small screen. Desktop (lg:) breakpoint additions are primarily cosmetic — revealing labels next to icons, adjusting button widths — rather than restructuring the layout.

// Desktop breakpoints reveal text that is hidden on mobile
<Button size="icon" className="lg:w-auto lg:px-3">
<Plus />
<span className="hidden lg:inline">Add</span>
</Button>
// Navigation adapts from bottom bar (mobile) to sidebar (desktop)
className="lg:flex lg:hidden"

Breakpoints

Tailwind’s default breakpoints are available. Only two are actively used in the codebase:

BreakpointWidthUsage in app
sm640pxRare — occasional flex-row reflow on small tablets
md768pxOccasional text size adjustments
lg1024pxPrimary desktop breakpoint — sidebar nav, label reveals, icon button expansion
xl1280pxNot used
2xl1536pxNot used

The lg: breakpoint is the single practical threshold between the mobile and desktop experiences.

Flex vs grid

Both flex and grid are used, but for different purposes:

Flexbox — for rows and linear arrangements

Flex is the default layout for most UI rows: toolbars, list items, badge rows, button groups. It handles horizontal alignment and flex-1 expansion naturally.

// Toolbar row
<div className="flex items-center gap-2">
<span className="flex-1">{title}</span>
<Button />
</div>
// Badge/tag row (wrapping)
<div className="flex flex-wrap gap-1.5">
{tags.map(tag => <Badge key={tag.id} />)}
</div>

Grid — for structured two-dimensional layouts

Grid is used for page-level slot layouts (e.g. grid-rows-[auto_1fr] for a fixed toolbar + scrollable content area) and for multi-column settings forms.

// Page layout: toolbar row + scrollable body
<div className="h-[100cqh] grid grid-rows-[auto_1fr]">
<div>{/* Toolbar */}</div>
<div className="overflow-y-auto">{/* Scrollable list */}</div>
</div>
// Settings form
<div className="grid grid-cols-2 gap-4">
{/* … */}
</div>

Max-width and containers

The app uses max-w-* constraints in dialogs, forms, and settings panels — not on the main list views, which stretch to fill the available width.

ClassWidthWhere used
max-w-sm384pxOnboarding panels and narrow content sections
max-w-lg512pxDefault dialog width (Dialog and AlertDialog base)
max-w-2xl672pxSettings forms and detail pages

Global shell

The global Layout component wraps every page. It uses a two-column grid that adapts at the lg: breakpoint:

Layout.tsx
<div className="h-dvh bg-background-base grid grid-cols-[auto_1fr]">
<div className="overflow-y-auto">
<Sidebar /> {/* hidden by default; lg:flex */}
</div>
<div className="grid grid-rows-[1fr_auto]">
<main className="overflow-y-auto [container-type:size]">
{children}
</main>
<Navigation /> {/* bottom bar; lg:hidden */}
</div>
</div>

Mobile (< 1024px): the sidebar column collapses (hidden), giving the main content full width. A four-tab bottom navigation bar occupies the auto row below, on pages without a Back button in their top bar. A page with a Back button in its top bar has no bottom bar (see Back Navigation), so its content fills the whole height.

Desktop (≥ 1024px): a w-56 sidebar fills the auto column on the left. The bottom bar is hidden, so the main content fills the full viewport height.

Mobile Desktop
┌──────────────────────┐ ┌────────┬───────────────────┐
│ │ │ │ │
│ Main content │ │Sidebar │ Main content │
│ (full width) │ │ w-56 │ (remaining) │
│ │ │ │ │
├──────────────────────┤ └────────┴───────────────────┘
│ Bottom nav (4 tabs) │
└──────────────────────┘

Page layout patterns

Three patterns are used across the app. The outer shell differs between breakpoints (sidebar vs bottom nav), but the page-level structure is the same.

The header rows of an item list (row 1, row 2, one line, and the Select mode bar) have their own page: List Toolbars.

One height rule. Only Layout is sized to the viewport (h-dvh). Every page sizes itself to Layout’s <main> with h-[100cqh] or min-h-[100cqh]. Do not use h-screen, min-h-screen or any vh / svh / lvh / dvh height on a page: on iOS in home-screen mode 100vh can be taller than 100dvh, which leaves empty space at the bottom of the page. The test apps/web/src/lib/pageHeightRule.test.ts fails when a page breaks this rule.

Mobile

Toolbar + list + bottom nav
Toolbar + list
Toolbar + form

Toolbar + list + bottom nav — pages with no Back button: Pantry (its list, and its lists of shelves, vendors and recipes), Shopping, Cooking and the settings menu (/settings, since 2026-12-05). The toolbar shows a page title and an optional action button. The bottom nav sits outside the page content in the outer shell.

<div className="h-[100cqh] grid grid-rows-[auto_1fr]">
<div>{/* Toolbar: title + optional action button */}</div>
<div className="overflow-y-auto [container-type:size]">
{/* Scrollable content */}
</div>
</div>

h-[100cqh] sizes to the container query height of Layout’s <main> — the viewport minus the bottom nav height.

Toolbar + list — every page with a Back button in its top bar: a vendor’s cart, a shelf, vendor or recipe view in Pantry, an item page, and the settings pages below the settings menu. The toolbar requires a back button, and there is no bottom nav. h-[100cqh] fills Layout’s <main>.

<div className="h-[100cqh] grid grid-rows-[auto_1fr]">
<div>{/* Toolbar: back button + title */}</div>
<div className="overflow-y-auto [container-type:size]">
{/* Scrollable content */}
</div>
</div>

Toolbar + form — entity configuration pages (item info, tag, vendor, recipe, shelf forms). The toolbar requires a back button and is provided by the parent route. Form content fills at least the screen height.

<div className="p-4 bg-background-elevated min-h-[100cqh]">
{/* Form content */}
</div>

Desktop

Sidebar + toolbar + list
Toolbar + list
Toolbar + form

Sidebar + toolbar + list — level 1 pages with the w-56 sidebar in the left column. No bottom nav; h-[100cqh] fills the full viewport height since there is no bottom nav offset.

<div className="h-[100cqh] grid grid-rows-[auto_1fr]">
<div>{/* Toolbar: title + optional action button */}</div>
<div className="overflow-y-auto [container-type:size]">
{/* Scrollable content */}
</div>
</div>

Toolbar + list — item pages and one location, tag, vendor, recipe or shelf: no sidebar, no bottom nav. The toolbar requires a back button. h-[100cqh] fills Layout’s <main>. A vendor’s cart, a shelf, vendor or recipe view in Pantry, and the settings section pages keep the sidebar on desktop (the first pattern), even though they have a Back button.

<div className="h-[100cqh] grid grid-rows-[auto_1fr]">
<div>{/* Toolbar: back button + title */}</div>
<div className="overflow-y-auto [container-type:size]">
{/* Scrollable content */}
</div>
</div>

Toolbar + form — same as mobile: no sidebar, no bottom nav. Back button toolbar from the parent route; padded form content in the child route.

<div className="p-4 bg-background-elevated min-h-[100cqh]">
{/* Form content */}
</div>

Rules of thumb

  • Design for mobile first — the default layout should work on a 375px screen.
  • Use lg: to add desktop enhancements, not to fix mobile layouts.
  • Use flex for linear rows and wrapping sets; use grid for two-dimensional page slots.
  • Apply max-w-* constraints to dialogs and forms, not to full-page lists.
  • Do not use custom pixel values for breakpoints — snap to sm/md/lg.