docs / composition
gru · 0.7.0
Composition
How to structure pages: pick a shell, put lists in Panel/Card, reuse demo patterns for controls.
Rules
- Go-first · compose widgets in Go. Optional
.gruis just structure. - One job per layer · shell → (optional viewport) → Panel / Card → children.
- Surfaces host lists · dense
ListTilestacks live in a Panel or Card. - No new wrapper widgets when Panel, Card, Container, and ListTile already cover it.
- Borrow controls from demos · copy a pattern, not a whole private app shell.
- Name the height mode · intrinsic, fill (
FlexGrow), or fixed.
Shell matrix
| Shell ID | Use when | Demo |
|---|---|---|
CP-SHELL-PAGE | Scrollable demo / document pages | Form Demo |
CP-SHELL-APPSHELL | AppBar + scroll / fill body | App Shell (Go) |
CP-SHELL-DESKTOP | MenuBar + nav rail + main | Desktop Shell (Go) |
CP-SHELL-EDGE | Full-bleed utility chrome | List Pane · Settings Desktop |
CP-SHELL-GRID | Fixed 12-col grids | Responsive Grid |
Default for new apps / samples: flex column root + Card / Panel
(samples/hello), or CP-SHELL-PAGE when using demo helpers.
Surfaces
| Widget | Role |
|---|---|
Panel | Framed region, optional title / scroll |
Card | Section surface inside a page |
ListTile | Row in a list (title, subtitle, trailing) |
Container | Layout grouping (not a styled panel substitute) |
Prefer theme styles (card, panel, list-tile, form-label) over one-off colors.
Borrow matrix (public)
| You want | Borrow from |
|---|---|
| Page + cards | Card Nest (Go) |
| Desktop rail | Desktop Shell (Go) |
| AppBar + FAB | App Shell (Go) |
| Desktop settings rows | Settings · Desktop (Go) |
| List + detail | List Pane (Go) |
| Forms | Form Demo + field batches |
| Overlays | Batch 1 · Modal; Batch 7 · Toast |
| WebView embed | WebView Module / Focus Handoff |
| Signals starter | Counter Demo |
Modals & overlays
- Modal body = flat flex only; never use a
Viewportas the modal root. - Toasts / tooltips / context menus use overlay managers (after blit).
- Modal over WebView → host occlusion (hide HWND), not click-through.
Full cookbook in the repo: COMPOSITION.md. Layout contracts: architecture/layout.md.
Next: Widgets · Demos · Architecture