Grid
Build grid-based layouts using CSS Grid
Use the Grid
component to build grid-based layouts and organize your content into up to 8 columns. To use the Grid
component, make sure you don’t have the includeUtilities
rule disabled in your setup
mixin (this rule is enabled by default):
Grid
component only supports setting gaps and columns. If you need a complex setup, please use CSS instead. You can also use CSS utility classes without the Grid
component. You can read more in the Layout section. Simply pass your elements or components inside the Grid
component to display them in a grid container. By default, the element will be rendered as a div
. This can be changed using the element
prop:
Gap
The gap between grid items is set to 20px by default. To change this, use the gap
prop with one of the following values:
Prop value | Default value |
---|---|
none | 0 |
xxs | 2px |
xs | 5px |
sm | 10px |
md | 15px |
default | 20px |
lg | 25px |
xl | 30px |
xl2 | 35px |
xl3 | 40px |
xl4 | 45px |
xl5 | 50px |
You can configure your gaps using the webcore.config.scss
configuration file. Read more about how to configure gaps in the CSS configuration documentation.
Column
To set the number of columns for your grid container, you can use the column
prop:
You can set the column
prop up to 3
which will set the number of columns for all devices. To set columns up to 8
on larger breakpoints, you can use a responsive value:
Responsiveness
The above properties can also be used responsively. Simply pass an object for the prop that you’d like to change based on media queries, and define the following props:
All breakpoints are optional, you can create the object as needed.
webcore.config.scss
configuration file. Read more in the CSS Configurations guide to see examples. API
Prop | Default | Purpose |
---|---|---|
element | div | Set the HTML tag used for the grid container. |
gap | 20px | Sets the gap between grid items. |
column | 1 | Sets the number of grid columns. |
className | - | Pass additional CSS classes for the element. |
Request improvement for this page