<bolt-grid>
<bolt-grid-item>
<!-- Content goes here -->
</bolt-grid-item>
<bolt-grid-item>
<!-- Content goes here -->
</bolt-grid-item>
</bolt-grid>
Prop Name | Description | Type | Default Value | Option(s) |
---|---|---|---|---|
attributes
|
A Drupal-style attributes object with extra attributes to append to this component. |
object
| — |
|
gutter
|
Spacing between the columns of the grid. |
string
|
medium
|
|
row_gutter
|
Spacing between the rows of the grid. |
string
|
medium
|
|
items
|
Array of grid items to render inside the grid. |
array
| — |
|
Prop Name | Description | Type | Default Value | Option(s) |
---|---|---|---|---|
attributes
|
A Drupal-style attributes object with extra attributes to append to this component. |
object
| — |
|
valign
|
Vertical alignment of the grid item itself |
string
|
auto
|
|
column_start
|
The general column the grid item should start on. For example, a |
string
| — |
|
column_end
|
The general column the grid item should stop on. For example, a |
string
| — |
|
column_span
|
The number of columns the |
string
| — |
|
row_start
|
Specifies a grid item’s start position within the grid row |
string
|
auto
|
|
row_end
|
Specifies a grid item’s ending position within the grid row |
string
|
auto
|
|
row_span
|
Specifies the number of rows a |
string
|
auto
|
|
npm install @bolt/layouts-grid
By using The Grid to design layouts, consistency is guaranteed. If your goal is to confine your layout to a 12-column grid and have elements spaced and lined up consistently using the Bolt spacing system, The Grid is for you. Otherwise, you should not use The Grid, there is the List component for simple layouts and alignments.
{% include '@bolt-layouts-grid/grid.twig' with {
items: [
{
content: 'Grid item',
},
{
content: 'Grid item',
},
...
]
} only %}
<bolt-grid>
<bolt-grid-item>
<!-- Content goes here -->
</bolt-grid-item>
<bolt-grid-item>
<!-- Content goes here -->
</bolt-grid-item>
...
</bolt-grid>
{% include '@bolt-layouts-grid/grid.twig' with {
items: [
{
column_start: '1',
column_span: '2',
content: item_aside,
},
{
column_start: '3',
column_span: '8',
content: item_main,
},
{
column_start: '11',
column_span: '2',
content: item_aside,
},
]
} only %}
<bolt-grid>
<bolt-grid-item column-start="1" column-span="2">
<!-- Aside Content -->
</bolt-grid-item>
<bolt-grid-item column-start="3" column-span="8">
<!-- Main Content -->
</bolt-grid-item>
<bolt-grid-item column-start="11" column-span="2">
<!-- Aside Content -->
</bolt-grid-item>
</bolt-grid>
gutter
, is configurable with the variable of the same name. The default value is medium
.
{% include '@bolt-layouts-grid/grid.twig' with {
gutter: 'large',
...
} only %}
<bolt-grid gutter="large">
<!-- Grid Items -->
</bolt-grid>
rowigutter
or row_gutter
, is configurable with the variable of the same name. The default value is medium
.
{% include '@bolt-layouts-grid/grid.twig' with {
row_gutter: 'large',
...
} only %}
<bolt-grid row-gutter="large">
<!-- Grid Items -->
</bolt-grid>
{% include '@bolt-layouts-grid/grid.twig' with {
items: [
{
column_start: '1',
column_span: '3',
content: item_1,
},
{
column_start: '4',
column_span: '9',
content: item_2,
},
]
} only %}
<bolt-grid>
<bolt-grid-item column-start="1" column-span="3">
<!-- Item 1 Content -->
</bolt-grid-item>
<bolt-grid-item column-start="4" column-span="9">
<!-- Item 2 Content -->
</bolt-grid-item>
</bolt-grid>
{% include '@bolt-layouts-grid/grid.twig' with {
items: [
{
row_span: '3',
...
},
]
} only %}
<bolt-grid>
<bolt-grid-item row-span="3">
<!-- Item Content -->
</bolt-grid-item>
</bolt-grid>
Use the @breakpoint
options to do advanced responsive layouts. More information about breakpoints can be found on the dedicated page.
{% include '@bolt-layouts-grid/grid.twig' with {
items: [
{
column_start: '1',
column_span: '12 4@small 3@medium',
row_start: '2 1@small',
content: item_1,
},
{
column_start: '1 5@small 4@medium',
column_span: '12 8@small 9@medium',
row_start: '1 1@small',
content: item_2,
},
]
} only %}
<bolt-grid>
<bolt-grid-item row-start="2 1@small" column-start="1" column-span="12 4@small 3@medium">
<!-- Item Content -->
</bolt-grid-item>
<bolt-grid-item row-start="1 1@small" column-start="1 5@small 4@medium" column-span="12 8@small 9@medium">
<!-- Item Content -->
</bolt-grid-item>
</bolt-grid>
The alignment must be set manually by using column start and column span, that way the user can position the item exactly as intended with the flexibility doing more than the common start, center, and end alignments.
{% include '@bolt-layouts-grid/grid.twig' with {
items: [
{
column_start: '9',
column_span: '4',
content: item_end,
},
]
} only %}
<bolt-grid>
<bolt-grid-item column-start="9" column-span="4">
<!-- Item Content -->
</bolt-grid-item>
</bolt-grid>
Vertical alignment of an item can simply be defined by the valign
prop.
{% include '@bolt-layouts-grid/grid.twig' with {
items: [
{
valign: 'end',
...
}
]
} only %}
<bolt-grid>
<bolt-grid-item valign="end">
<!-- Item Content -->
</bolt-grid-item>
</bolt-grid>
{% set row %}
{% include '@bolt-layouts-grid/grid.twig' with {
items: [
{
column_start: '1',
column_span: '4',
content: item,
},
{
column_start: '5',
column_span: '4',
content: item,
},
{
column_start: '9',
column_span: '4',
content: item,
},
]
} only %}
{% endset %}
{% include '@bolt-layouts-grid/grid.twig' with {
items: [
{
column_start: '1',
column_span: '12',
row_start: '1',
row_span: '1',
content: row,
},
{
column_start: '1',
column_span: '12',
row_start: '2',
row_span: '1',
content: row,
}
]
} only %}
<bolt-grid>
<bolt-grid-item row-start="1" row-span="1" column-start="1" column-span="12">
<bolt-grid>
<bolt-grid-item column-start="1" column-span="4">
<!-- Item Content -->
</bolt-grid-item>
<bolt-grid-item column-start="5" column-span="4">
<!-- Item Content -->
</bolt-grid-item>
<bolt-grid-item column-start="9" column-span="4">
<!-- Item Content -->
</bolt-grid-item>
</bolt-grid>
</bolt-grid-item>
<bolt-grid-item row-start="2" row-span="1" column-start="1" column-span="12">
<bolt-grid>
<bolt-grid-item column-start="1" column-span="4">
<!-- Item Content -->
</bolt-grid-item>
<bolt-grid-item column-start="5" column-span="4">
<!-- Item Content -->
</bolt-grid-item>
<bolt-grid-item column-start="9" column-span="4">
<!-- Item Content -->
</bolt-grid-item>
</bolt-grid>
</bolt-grid-item>
</bolt-grid>