Skip to content
Content Blocks docsv0.8.0Website

Docs / Formatters

<content-grid-formatter>

Lays its children out in a grid or a row, with the number of columns, gaps and alignment set per breakpoint.

Import it on its own, for a bundler
import '@content-blocks/js/components/content-grid-formatter';

Examples

A responsive grid

One column on phones, two from 768px and three from 1024px, with no media queries.

Open on its own
Midgard Asgard Vanaheim Jotunheim Alfheim Niflheim

Anatomy

Content goes into the component's slots, chosen with the slot attribute on each child.

flowchart LR
  root["#lt;content-grid-formatter#gt;"]:::component
  root --> s0["<b>no slot (default)</b><br/>The default slot"]
  root --> s1["<b>slot=#quot;content#quot;</b><br/>This slot will usually serve a content text block."]
  root --> s2["<b>slot=#quot;media#quot;</b><br/>This slot can either be a video or image component."]
  classDef component fill:#141413,color:#faf9f5,stroke:#141413
The slots of <content-grid-formatter>
SlotWhat goes in it
(default)The default slot
slot="content"This slot will usually serve a content text block.
slot="media"This slot can either be a video or image component.

Properties

Set them as attributes. Those marked responsive take a value per breakpoint, separated by pipes and named or in order: 1|tablet=2 or 1|2. Seeresponsive values.

AttributeTypeDefaultDescription
classesresponsiveString–Classes to add to the component. Use pipes for different classes per breakpoint, by name or in order: classes="stacked|laptop=side-by-side".
column-gapresponsiveNumber'0'Not documented yet
columnsresponsiveNumber'1'Not documented yet
directionresponsiveSelect

row · column

'row'For type flex: lay the children out in a row or a column. With columns="auto", children in a column keep their own width, so a list of links stacks on phones and sits in a row on larger screens.
flex-growresponsiveBoolean'false'Setting this true to will grow all children. Alternatively, add the attribute [flex-grow="true"] to a specific grid child and that child will grow.
flex-shrinkresponsiveBoolean'false'Setting this true to will shrink all children. Alternatively, add the attribute [flex-shrink="true"] to a specific grid child and that child will shrink.
horizontalresponsiveSelect

flex-start · space-between · center · space-evenly

'space-between'Horizontal axis alignment
paddingresponsiveString–Padding around the component, written as CSS padding. Use pipes for different padding per breakpoint, by name or in order: padding="1rem|tablet=2rem 4rem" or padding="1rem|2rem 4rem|3rem 5rem 4rem".
row-gapresponsiveNumber'0'Not documented yet
typeresponsiveSelect

none · flex · grid

'flex'Flex or grid
verticalresponsiveSelect

flex-start · space-between · center · space-evenly

'space-between'Vertical axis alignment
flowchart LR
  v["columns=#quot;1|2|3#quot;"]:::value
  v --> b0["mobile, from 0px: 1"]
  v --> b1["tablet, from 768px: 2"]
  v --> b2["laptop and up, from 1024px: 3"]
  classDef value fill:#1d4ed8,color:#fff,stroke:#1d4ed8
How columns="1|2|3" from the examples applies at each breakpoint