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.
| Primitive | What it does | Main classes |
|---|---|---|
| Container | Readable width, centred, with side gutters | container, max-w-default, max-w-reader |
| Grid | Columns that adapt to the screen | grid-layout, grid-col-span-*, grid grid-cols-* |
| Stack | Items in a column or row with an even gap | flex flex-col, flex-row, gap-* |
| Text | Named text styles | f-heading-*, f-body-*, f-ui-*, f-label |
| Box | A surface: background, border, radius, padding | bg-*, 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) ormax-w-reader(1224px) withmx-auto: caps the width on large screens.
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.
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-*:
Stack
Puts items one under another, or side by side, with the same gap between each.
| Stack | Classes |
|---|---|
| Vertical | flex flex-col gap-16 |
| Horizontal, wraps when full | flex flex-wrap items-center gap-12 |
| Vertical on phones, row from 750px | flex flex-col md:flex-row gap-24 |
| Push the last item to the end | add justify-between |
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.
| Class | Use for |
|---|---|
f-display-01, f-display-02 | Hero headlines on landing pages |
f-heading-01 … f-heading-06 | Headings, from page title down |
f-body-01 | Lead paragraphs |
f-body-02, f-body-03 | Body text |
f-ui-01 … f-ui-05 | Interface text: buttons, menus, form fields, small print |
f-label | Labels, tags, eyebrows (IBM Plex Mono) |
f-caption | Captions and footnotes |
f-code | Inline 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.
| Part | Classes |
|---|---|
| Background | bg-inverse (white), bg-dark (brand grey #ECECEC), bg-strongest (brand black, use with text-inverse) |
| Border | border plus a colour: border-softer, border-soft, border-default |
| Radius | rounded-xs 4px, rounded-sm 8px, rounded-md 12px, rounded-lg 16px, rounded-pill |
| Padding | p-*, px-*, py-*, pt-*, pb-* on the spacing scale, with md: and lg: versions |
| Elevation | shadow-small (cards), shadow-medium (menus, popovers) |
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.