Layout Primitives

Five building blocks lay out every EBRAINS page: Container, Grid, Stack, Text and Box. They are CSS classes in @ebrains/assets, not components, so they work in plain HTML and every framework, with no JavaScript and no flash while loading.

Use them instead of writing your own widths, gaps and font sizes: the spacing and rhythm are decided once, and every app gets them right by default.

PrimitiveWhat it doesMain classes
ContainerReadable width, centred, with side gutterscontainer, max-w-default, max-w-reader
GridColumns that adapt to the screengrid-layout, grid-col-span-*, grid grid-cols-*
StackItems in a column or row with an even gapflex flex-col, flex-row, gap-*
TextNamed text stylesf-heading-*, f-body-*, f-ui-*, f-label
BoxA surface: background, border, radius, paddingbg-*, border, rounded-*, p-*, shadow-*

Always available. Every class on this page is guaranteed in @ebrains/assets/styles/output.css, whatever the components use internally. The guaranteed set is new: it ships with the next @ebrains/assets release after 0.9.0. Until then, some responsive and spacing variants may be missing from the CDN file.

Breakpoints for the responsive prefixes: md: from 750px, lg: from 900px, xl: from 1024px. Without a prefix a class applies at every size; a prefixed class takes over from that width up.

Spacing scale for gaps and padding: 0, 4, 8, 12, 16, 24, 32, 48, 64 (pixels).

Container

Keeps content off the screen edges and at a readable width.

  • container: full width minus the outer gutter on each side (16px on phones, 20px from 750px, 28px from 900px), centred.
  • max-w-default (1440px) or max-w-reader (1224px) with mx-auto: caps the width on large screens.
container max-w-default mx-auto

Use one container per page section; don’t nest containers.

Grid

The 12-column grid

grid-layout creates the EBRAINS 12-column grid with the standard gutter (8px on phones, 12px from 750px, 16px from 900px). Children say how many columns they take with grid-col-span-*: 2, 3, 4, 6, 8, 12 or full, with md:, lg: and xl: versions.

span 12 → lg 8
span 12 → lg 4

A grid-layout inside a spanning child gets that many columns: inside grid-col-span-6, a nested grid has 6 columns.

Equal columns

For a set of equal items (cards, tiles), use grid with grid-cols-* (1, 2, 3, 4, 6 or 12, with md:, lg:, xl: versions) and a gap-*:

1
2
3

Stack

Puts items one under another, or side by side, with the same gap between each.

StackClasses
Verticalflex flex-col gap-16
Horizontal, wraps when fullflex flex-wrap items-center gap-12
Vertical on phones, row from 750pxflex flex-col md:flex-row gap-24
Push the last item to the endadd justify-between
flex-1
flex-1
auto

Choosing the gap: 4–8 inside one control (icon and label), 12–16 between related items, 24–32 between groups, 48–64 between page sections. Use gap-x-* and gap-y-* to set the two directions separately. Gaps also take md: and lg: prefixes.

Other helpers: items-start|center|end|stretch|baseline (cross-axis alignment), justify-start|center|end|between (main axis), flex-1 (take the remaining space), shrink-0 (never squash).

Text

Text styles are named f-* classes. Each sets the font, size, weight, line height and letter spacing together, and scales with the screen. Don’t set font sizes by hand.

ClassUse for
f-display-01, f-display-02Hero headlines on landing pages
f-heading-01 … f-heading-06Headings, from page title down
f-body-01Lead paragraphs
f-body-02, f-body-03Body text
f-ui-01 … f-ui-05Interface text: buttons, menus, form fields, small print
f-labelLabels, tags, eyebrows (IBM Plex Mono)
f-captionCaptions and footnotes
f-codeInline code and data values

Align text with text-left, text-center or text-right (also with md: and lg:). See Typography for the sizes at each breakpoint and the typefaces.

Box

A Box is any surface: a panel, a callout, an empty-state frame. Combine a background, an optional border, a radius and padding.

PartClasses
Backgroundbg-inverse (white), bg-dark (brand grey #ECECEC), bg-strongest (brand black, use with text-inverse)
Borderborder plus a colour: border-softer, border-soft, border-default
Radiusrounded-xs 4px, rounded-sm 8px, rounded-md 12px, rounded-lg 16px, rounded-pill
Paddingp-*, px-*, py-*, pt-*, pb-* on the spacing scale, with md: and lg: versions
Elevationshadow-small (cards), shadow-medium (menus, popovers)
bg-inverse border border-softer rounded-lg p-24
bg-dark rounded-lg p-24
bg-strongest text-inverse rounded-lg p-24

Putting them together

A typical content page: a container, a grid for the main column and sidebar, stacks inside, text styles for the type, and a box for a callout.

For whole-page structures built from these, see Templates. For the grid tokens and more grid options, see Layout.