London City Data

Layout grid

Contained and fluid page layouts

A page uses one of two layouts: contained, for pages people read, or fluid, for dashboards and application shells.

The layout's container sets the width of the page and the padding at its edge. The space between tiled blocks, such as cards, is the default flow step of the context.

Use

Put a layout class on the element that holds the page content. Use .container for an article, documentation or a form, and .container-fluid for a dashboard or an application shell:

<main class="container-fluid">…</main>

To tile cards or panels, put gap-flow on the grid or flex container. The gap is the default flow step of the context, so it changes when the grid moves into a different context:

<section class="flow-standard">
	<div class="gap-flow grid grid-cols-1 md:grid-cols-3">
		<Card title="Population">…</Card>
		<Card title="Housing">…</Card>
		<Card title="Transport">…</Card>
	</div>
</section>

The layout classes and gap-flow are in the theme package's CSS, so they work without Tailwind. The example sets columns with Tailwind's grid utilities, which the component library uses. CSS grid works as well.

How it works

Contained and fluid

The contained layout is for document-like pages, such as articles, documentation and forms. Its width steps up at each breakpoint, it is centred, and its padding grows with the viewport.

The fluid layout is for dashboards and application shells. It fills the width of the viewport, and its padding stays between 16px and 24px.

Placeholder: a diagram of the contained and fluid layouts at the base, md and xl breakpoints, showing the container width and padding. The breakpoint frames on the Figma Spacing page show these as layout grids, which don't export.
BreakpointMinimum widthContained widthContained paddingFluid padding
baseNone100%16px16px
sm640px640px32px16px
md768px768px32px24px
lg1024px1024px64px24px
xl1280px1280px80px24px
2xl1536px1536px96px24px

The page edge

The container's padding sets the page edge. Components don't add padding at the page edge. A component's own padding comes from the spacing scale, whatever layout it sits in.

Space between tiled blocks

The space between tiled blocks is the default flow step of the context, set with gap-flow. A row of cards and a stack of cards then have the same space between them.

Here the same three panels are tiled in a standard context and then in a spacious one:

<div class="flow-standard">
	<div class="gap-flow grid grid-cols-3">…</div>
</div>
 
<div class="flow-spacious">
	<div class="gap-flow grid grid-cols-3">…</div>
</div>

Standard: 8px between panels

Spacious: 16px between panels

A fixed gap, such as gap-4, doesn't follow the context. Use gap-flow.

Columns

There are no column tokens. The number of columns depends on the content of each page, so each page sets its own with CSS grid or Tailwind's grid utilities.

Reference

Container padding

TokenValuePixels
--grid-base-contained-container-padding1rem16px
--grid-base-fluid-container-padding1rem16px
--grid-sm-contained-container-padding2rem32px
--grid-sm-fluid-container-padding1rem16px
--grid-md-contained-container-padding2rem32px
--grid-md-fluid-container-padding1.5rem24px
--grid-lg-contained-container-padding4rem64px
--grid-lg-fluid-container-padding1.5rem24px
--grid-xl-contained-container-padding5rem80px
--grid-xl-fluid-container-padding1.5rem24px
--grid-2xl-contained-container-padding6rem96px
--grid-2xl-fluid-container-padding1.5rem24px

Breakpoints

BreakpointMinimum width
baseNone
sm640px
md768px
lg1024px
xl1280px
2xl1536px

The full rules for the layout grid are in the specification.