Grid
Usage
Grid component provides simple grid system based on flexbox container:
Gutter
Customize spacing between columns with gutter
prop on Grid component.
Use xs, sm, md, lg, xl values to set spacing from theme.spacing
or number to set spacing in px:
Grow
Set grow
prop on Grid component to force last row take 100% of container width:
Column offset
Set offset
prop on Grid.Col component to create gaps in grid.
offset
adds left margin to target column and has the same units as span
:
Multiple rows
Once children columns span and offset sum exceeds columns
prop (defaults to 12),
columns are placed on next row:
Justify and align
Since grid is a flexbox container, you can control justify-content
and align-items
properties:
Responsive columns
Use breakpoint props (xs
, sm
, md
, lg
, xl
) to make columns respond to viewport changes.
You can configure breakpoint values in MantineProvider.
In this example up to md
there will be 1 column, from md
to lg
there will be 2 columns and from lg
and up, there will be 4 columns:
Change columns count
By default, grid uses 12 columns layout, you can change it by setting columns
prop on Grid component.
Note that in this case, columns span and offset will be calculated relative to this value.
In this example, first column takes 50% with 12 span (12/24), second and third take 25% (6/24):
Wrap Grid.Col component
Grid.Col component depends on context props from Grid component. If you want to enhance it with additional logic – pass all props to child Gird.Col: