# Screen patterns

Every screen starts from one of five page frames and follows the same few patterns: one layer order, one way to group a dialog, one answer for each part on a phone. These are the patterns Werewolf suggests: agents follow them by default, and you are free to use them as they are, change them or create your own. These patterns are pending review.

## Pick the frame first

Map the request to the closest screen, then to its frame. Each frame has a layout table in DESIGN.md 9.

| Frame | Use when |
| --- | --- |
| `sidebar` | An app with several sections: dashboards, settings, data tables, admin. |
| `topbar` | An app whose navigation is one flat row, with no groups or nested items. |
| `focus` | One task with no navigation: sign in, sign up, verify a code, accept an invite. |
| `steps` | A linear flow of several screens: onboarding, import, checkout. |
| `marketing` | A public page: landing, pricing, changelog. |

Inside a frame, two arrangements: **split** puts a list beside the item it opens (below md the item replaces the list), **state** puts one EmptyState in the middle of the content: empty, not found, error, no access.

An agent never invents a new page frame on its own. When your product needs one, ask for it: your own patterns always come first.

## App shell

The Sidebar sits on the sunken canvas. The page content sits in one panel filled with the page color, 8px from the canvas, with the page radius, a border and no shadow. Cards on it keep their surface fill and border.

| Layer | Fill | Edge |
| --- | --- | --- |
| Canvas and `<Sidebar inset>` | `color-background-sunken` | None |
| `<SidebarInset>`, the panel | `color-background-page` | `color-border`, `radius-page` |
| Card on the panel | `color-background-surface` | `color-border`, no shadow |

Do: the navigation on the sunken canvas, the page in one panel, metrics in one frame, a card on the panel.
Avoid: the navigation and the page on one fill, the whole page in a card with a shadow.

Open a record in a right Sheet when people check it and go back to the list. Give it its own page when it has Tabs or history, needs a link to share, or people stay on it.

## Topbar

For navigation that is one flat row. There is no limit on the number of links on desktop; navigation that needs groups or levels uses the Sidebar.

- A sticky header, 56px tall, with a `border-b`: the brand, the links, search and the account. The current link sets `aria-current` and has a 2px underline.
- The content sits straight on the page in one column (`max-w-6xl`, `py-2xl`), sections `gap-2xl`. There is no inset panel.
- Below md the links move to a BottomNav, 3 to 5 destinations, the rest behind a More item.

Do: a header with a border, the content straight on the page.
Avoid: a header with a shadow and the content boxed in a panel.

## Dialogs with several regions

A dialog holds as much as its task needs. When it shows two or more separate regions, each one sits in a sunken well.

- A well is `color-background-sunken` with a border and no shadow, 4px or 8px in from the dialog edge.
- Its radius is the dialog radius minus that gap, so the corners stay concentric.
- Header and footer text lines up with the text inside the wells.
- Never put a raised or surface card inside a dialog: no layer is lighter than raised, so a lifted card has nowhere to go in dark mode. A dialog with one region and AlertDialog stay flat.

## Small screens

Below md the frame changes, never a component's size. Size follows the pointer, not the screen width.

### Tables

A table people compare across columns keeps its columns, scrolls sideways and pins its first column. A list of records people open turns each row into two lines, at least 44px tall, and the other columns move to the record's page. Never shrink the text to make columns fit.

Do: each record on two lines, the main figure in mono, the status as a Badge.
Avoid: every column squeezed onto a phone, cut and too small to read.

### Metrics

Four metrics become a 2 by 2 grid in the same frame (`grid-cols-2 md:grid-cols-4`). Three or five stack in one column divided by `border-t`. Charts go full width with the legend under them; the period toggle stays and the other filters go behind a Filters button.

Do: one frame, four cells, dividers between them.
Avoid: four separate cards stacked down the screen.

### Dialogs and forms

A dialog has no limit on what it holds. On a phone its frame follows its content.

| On desktop | Below md |
| --- | --- |
| AlertDialog | Stays a centered dialog. |
| A dialog that fits the screen | Stays a dialog, full width minus 16px on each side. |
| A dialog that has to scroll | A bottom Sheet that grows with its content, `lg` or `full`. |
| A short choice | A bottom Sheet `sm`. |
| A form in a right Sheet | A bottom Sheet with a full-width primary Button. |
| A form that needs its own link | A page with a sticky action bar, `border-t` plus the safe area. |

Do: a bottom Sheet that grows with its content, the main action full width.
Avoid: a wide dialog squeezed onto a phone, its content cut off.

## Permissions

- Hide what the person's role can never use, its navigation item too.
- Keep visible and disabled what they could get (ask an admin, change the plan), and say why: in helper text, or in a Tooltip on a focusable wrapper.
- A value they can read but not change is text, not a disabled field. A page they can't open is an EmptyState that says who can grant access.

Do: the read-only value as text, the disabled action with its reason.
Avoid: a disabled field that is only there to be read, a disabled action with no reason.

## Long text

- Truncate to one line only in slots with a fixed width: table cells, list rows, Sidebar items, tabs. Leave a way to read it all.
- Headings, body text, errors and toasts wrap; they are never cut. Button labels and Badges stay on one line: write a shorter label.
- Numbers and dates follow the page language through `Intl`, in mono with `tabular-nums`. Check screens with long Vietnamese strings at heading sizes.

Do: the heading wraps, the name in the row is cut and stays readable on its page.
Avoid: a heading cut short, a row name that wraps and pushes the figure down.

## States every screen ships

A screen is not done with only its full state.

| State | What it shows |
| --- | --- |
| Ready | The content. |
| Pending | The first load: a Skeleton after about 150ms, for at least 300ms. Later loads keep the content and dim it with `opacity-pending`. |
| Empty | An EmptyState that says what the empty thing is for, with one action. |
| No results | One line and a way to clear the filters, inside the list, so the header and filters stay put. |
| Error | What failed, that nothing was lost, and Try again. A failure that keeps the content is an Alert above it. |

Pending review. The rules behind these patterns are DESIGN.md 9.4 to 9.9, and rules 22 and 27 to 31 of the [Design skill](https://www.werewolf-ui.dev/docs/design-skill.md).
