Layout
Stack, Inline and Grid
The parents that own the gaps between siblings.
import { Grid, Inline, Stack } from 'faifo-design'A component owns its inside spacing; the gap between two components belongs to their parent. Stack
arranges children vertically, Inline in a wrapping row and Grid in fixed columns. All three take
their gaps from the spacing tokens, so the same role has the same distance on every screen.
#When to use
- Use
Stackfor the vertical rhythm of a region.divideddraws a hairline between peer groups without framing any of them. - Use
Inlinefor a row of small things that may wrap: badges, actions, facts. - Use
Gridwhen the number of columns is a decision. UseCardGridwhen it should follow the available width. - Do not add margins to a child to push it away from its neighbour. Change the parent's
gap.
#Examples
Each example is a specimen of the package catalogue, rendered on the server exactly as shown in its code.
#Surface and section
Layout components establish rhythm without domain assumptions.
Operations
Daily overview
The section owns hierarchy; its body remains application data.
Orders
148
+12.4% vs previous 7 days
+12 today
Review queue
7
+3 since yesterday
Oldest 42 min
Blocked
2
Credential required
Archived
1 204
No state to report
Show codeHide code
import { Grid, Icon, LinkButton, Metric, Section } from 'faifo-design'
export const Example = () => (
<Section
eyebrow="Operations"
title="Daily overview"
description="The section owns hierarchy; its body remains application data."
actions={<LinkButton label="View report" href="#patterns" size="compact" />}
body={
<Grid
columns={4}
items={[
<Metric
label="Orders"
value="148"
detail="+12 today"
tone="positive"
change={{ label: '+12.4% vs previous 7 days', direction: 'up', tone: 'positive' }}
icon={<Icon name="shopping-bag" />}
/>,
<Metric
label="Review queue"
value="7"
detail="Oldest 42 min"
tone="warning"
href="#surface-section"
change={{ label: '+3 since yesterday', direction: 'up', tone: 'danger' }}
/>,
<Metric label="Blocked" value="2" detail="Credential required" tone="danger" />,
<Metric label="Archived" value="1 204" detail="No state to report" />,
]}
/>
}
/>
)#Stack with a scrolling child
A wrapper such as a client island stays within the stack; its table scrolls locally and each two-line cell keeps its text.
| Leg 1 | Leg 2 | Leg 3 | Leg 4 | Leg 5 | Leg 6 | Leg 7 | Leg 8 |
|---|---|---|---|---|---|---|---|
DELIVERY-1North terminal · North terminal · signed on arrival | DELIVERY-1North terminal · Harbour depot · signed on arrival | DELIVERY-1North terminal · Airport cargo · signed on arrival | DELIVERY-1North terminal · Riverside warehouse · signed on arrival | DELIVERY-1North terminal · Old town hub · signed on arrival | DELIVERY-1North terminal · Dry dock · signed on arrival | DELIVERY-1North terminal · Rail yard · signed on arrival | DELIVERY-1North terminal · Customs gate · signed on arrival |
DELIVERY-2Harbour depot · North terminal · signed on arrival | DELIVERY-2Harbour depot · Harbour depot · signed on arrival | DELIVERY-2Harbour depot · Airport cargo · signed on arrival | DELIVERY-2Harbour depot · Riverside warehouse · signed on arrival | DELIVERY-2Harbour depot · Old town hub · signed on arrival | DELIVERY-2Harbour depot · Dry dock · signed on arrival | DELIVERY-2Harbour depot · Rail yard · signed on arrival | DELIVERY-2Harbour depot · Customs gate · signed on arrival |
DELIVERY-3Airport cargo · North terminal · signed on arrival | DELIVERY-3Airport cargo · Harbour depot · signed on arrival | DELIVERY-3Airport cargo · Airport cargo · signed on arrival | DELIVERY-3Airport cargo · Riverside warehouse · signed on arrival | DELIVERY-3Airport cargo · Old town hub · signed on arrival | DELIVERY-3Airport cargo · Dry dock · signed on arrival | DELIVERY-3Airport cargo · Rail yard · signed on arrival | DELIVERY-3Airport cargo · Customs gate · signed on arrival |
DELIVERY-4Riverside warehouse · North terminal · signed on arrival | DELIVERY-4Riverside warehouse · Harbour depot · signed on arrival | DELIVERY-4Riverside warehouse · Airport cargo · signed on arrival | DELIVERY-4Riverside warehouse · Riverside warehouse · signed on arrival | DELIVERY-4Riverside warehouse · Old town hub · signed on arrival | DELIVERY-4Riverside warehouse · Dry dock · signed on arrival | DELIVERY-4Riverside warehouse · Rail yard · signed on arrival | DELIVERY-4Riverside warehouse · Customs gate · signed on arrival |
DELIVERY-5Old town hub · North terminal · signed on arrival | DELIVERY-5Old town hub · Harbour depot · signed on arrival | DELIVERY-5Old town hub · Airport cargo · signed on arrival | DELIVERY-5Old town hub · Riverside warehouse · signed on arrival | DELIVERY-5Old town hub · Old town hub · signed on arrival | DELIVERY-5Old town hub · Dry dock · signed on arrival | DELIVERY-5Old town hub · Rail yard · signed on arrival | DELIVERY-5Old town hub · Customs gate · signed on arrival |
Show codeHide code
import { FaifoTable, Stack, Text } from 'faifo-design'
// faifoTableDemoConfig: a catalogue fixture, packages/faifo-design/src/interactions/faifo-table/demo.ts
export const Example = () => {
const lines = (title: string, detail: string) => (
<Stack
gap="none"
items={[
<Text variant="bodyMd" children={title} />,
<Text variant="bodySm" tone="muted" children={detail} />,
]}
/>
)
const stops = [
'North terminal',
'Harbour depot',
'Airport cargo',
'Riverside warehouse',
'Old town hub',
]
// Eight legs make the table wider than the canvas at every catalogue width.
const legs = [...stops, 'Dry dock', 'Rail yard', 'Customs gate']
return (
<Stack
items={[
<Text children="The layout keeps its width; the table scrolls in its own region." />,
<div>
<FaifoTable
caption="Deliveries"
rows={stops.map((stop, index) => ({ id: `delivery-${index + 1}`, stop }))}
id={(row) => row.id}
rowHref={(row) => `#stack-scroll-boundary-${row.id}`}
columns={legs.map((leg, column) => ({
key: `leg-${column + 1}`,
label: `Leg ${column + 1}`,
cell: (row: { id: string; stop: string }) =>
lines(row.id.toUpperCase(), `${row.stop} · ${leg} · signed on arrival`),
}))}
labels={faifoTableDemoConfig.labels}
/>
</div>,
]}
/>
)
}#Contract
#Stack and local scrolling
Only the page header belongs directly on canvas. Other record content, including notices, facts and forms, belongs inside a working Surface. Keep each block's title inside its own Surface; do not frame the entire page. Section groups are internal and do not create a working surface.
Peer sections on one surface use Stack({ divided: true }). The stack owns one
1px --faifo-panel-border hairline and its gap on both sides. Flattening a child
Disclosure or Surface removes that child's frame, preserving the parent's divider,
including in flat presentation. See catalogue specimen peer-section-dividers.
A Disclosure line may start with leading, a small image or icon of the item (a
Thumbnail of size small for a product variant), before its label and meta.
The slot keeps its own size on the line's centre; without it the summary's markup is
unchanged.
A table's scroll region (ft-scroll of FaifoTable, table-scroll of DataTable) is the
boundary of its width: it contains its inline size (contain: inline-size), so the table
scrolls inside the region and never widens a parent Stack, a wrapping client island or the
page. Stack keeps an auto column and its children their default minimum, so a Stack
inside a table cell still reports its text as min-content and two-line cells never
collapse and overlap. Do not give the Stack a minmax(0, 1fr) track or shrink its
children, clip it, or add width overrides in consumers. See catalogue specimen
stack-scroll-boundary.
DataTable raises visible row controls above a row-link overlay. It leaves hidden native controls in enhanced pickers in their own positioning context, so the form proxy cannot create an extra line box or displace the visible trigger.
In the mobile stacked presentation, a cell containing a text input, select, textarea or combobox uses a full-width row for its editable value. DataTable owns the label/value row and immediate child sizing; Field owns input typography and inside spacing. This also covers a Field composed inside Stack with a price hint, whose intrinsic flex width otherwise reduced a purchase price input to 24px. Read-only cells and desktop table geometry retain their existing layout.
AppTopbar's location strip lets the context shrink before its navigation, search
and account controls. Context copy should use Text's breakWord for long names.
#Side-by-side cards follow the room they have
Grid collapses to one column only below the 48rem viewport, so beside an open sidebar at 768px a
columns={2} grid gives each card about 14rem: a BarChart track shrinks to nothing and a list wraps
every line. Pass minimum (compact 12rem, default 17rem, wide 23rem, the CardGrid widths):
the grid keeps at most columns but drops one whenever a column would be narrower than the minimum,
measured on the grid itself rather than the viewport. Without minimum the fixed columns are unchanged.
Dashboard pairs (a work queue beside closing checks, two aging charts) use columns={2} minimum="wide".
Specimen: Columns by room in the layout rhythm primitives.
A BarChart shares one label and one value column across its rows from 48rem, so every track starts
and ends on one line however wide each printed value is.
#API
Generated from the package source. A property without a description has none in the source yet.
#GridComponent
Fixed columns. align="stretch" gives every block in a row the row's height, so side-by-side dashboard cards end on one line instead of leaving a hole under the shorter one. minimum (the CardGrid widths: 12, 17 or 23rem) keeps at most columns but drops one whenever a column would be narrower, so the grid follows the room it has (beside an open sidebar) rather than the viewport.
| Property | Description | Type | Default |
|---|---|---|---|
itemsrequired | – | readonly JSXChild[] | – |
columns | – | 2 | 3 | 4 | 3 |
mobileColumns | – | 1 | 2 | – |
gap | – | ResponsiveGap | – |
align | – | 'start' | 'stretch' | – |
minimum | – | 'compact' | 'default' | 'wide' | – |
#InlineComponent
| Property | Description | Type | Default |
|---|---|---|---|
itemsrequired | – | readonly JSXChild[] | – |
gap | – | ResponsiveGap | – |
align | – | 'start' | 'center' | 'end' | 'between' | – |
blockAlign | – | 'start' | 'center' | 'end' | 'baseline' | 'stretch' | – |
wrap | – | boolean | – |
#StackComponent
divided draws a hairline between items, the peer-section divider of Faifo Design visual contract L3 (a form with several groups, a list of sections in a modal). It never frames an item. print says how the stack behaves on a printed page.
| Property | Description | Type | Default |
|---|---|---|---|
itemsrequired | – | readonly JSXChild[] | – |
gap | – | ResponsiveGap | – |
inlineAlign | – | 'start' | 'center' | 'end' | 'stretch' | – |
divided | – | boolean | – |
print | On paper: keep moves the whole stack to the next page rather than splitting it, while it fits on one; omit leaves out what only serves the screen, such as a way back or a printing hint. | 'keep' | 'omit' | – |
#Types
#LayoutGap
type LayoutGap = 'none' | 'tight' | 'compact' | 'column' | 'default' | 'loose'#ResponsiveGap
type ResponsiveGap = LayoutGap | { desktop: LayoutGap; mobile: LayoutGap }