<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 '@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.
<content-grid-formatter type="grid" columns="1|2|3" column-gap="0.75rem" row-gap="0.75rem">
<content-line padding="1.25rem">Midgard</content-line>
<content-line padding="1.25rem">Asgard</content-line>
<content-line padding="1.25rem">Vanaheim</content-line>
<content-line padding="1.25rem">Jotunheim</content-line>
<content-line padding="1.25rem">Alfheim</content-line>
<content-line padding="1.25rem">Niflheim</content-line>
</content-grid-formatter>content-line {
font-weight: 600;
background: #dbeafe;
border-radius: 10px;
}// $ npm install @content-blocks/js
import '@content-blocks/js/components/content-grid-formatter';
import '@content-blocks/js/components/content-line';<script type="module"
src="https://cdn.jsdelivr.net/npm/@content-blocks/js/dist/content-blocks/content-blocks.esm.js"></script>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
| Slot | What 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.
| Attribute | Type | Default | Description |
|---|---|---|---|
classesresponsive | String | – | 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-gapresponsive | Number | '0' | Not documented yet |
columnsresponsive | Number | '1' | Not documented yet |
directionresponsive | Select | '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-growresponsive | Boolean | '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-shrinkresponsive | Boolean | '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. |
horizontalresponsive | Select | 'space-between' | Horizontal axis alignment |
paddingresponsive | String | – | 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-gapresponsive | Number | '0' | Not documented yet |
typeresponsive | Select | 'flex' | Flex or grid |
verticalresponsive | Select | '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
