Usage
The Grid Item component allows to easily create flexible, responsive designs, and organize content within a CSS grid container.
Here is an example of using Grid Item components inside Multi Column grid container:
Item 1
Item 2
::container
---
display: "grid"
grid-columns: 5
border: "1px solid gray"
---
:::grid-item
---
grid-column: "1/4"
grid-row: "1/3"
styles: "background-color: lightgray"
padding: "20px"
---
Item 1
:::
:::grid-item
---
grid-column: "4/ span 2"
styles: "background-color: #BDDAE4"
---
Item 2
:::
::
Props
gridColumn
The horizontal placement of the Grid Item within a grid container. This prop defines both the starting and ending positions of the item across the columns, allowing you to control how many columns the item spans. This property is defined by two values: the first value indicates the start line (where the item begins), and the second value indicates the end line (where the item ends).
Example:
// item will start on column 1 and ends before column 3
grid-column: "1 / 3"
// item will start on column 1 and will span 3 columns
grid-column: "1 / span 3"
- Type:
string
- Default:
'1'
::grid-item
---
grid-column: "1 / 3"
---
Learn, code, and build with our developer community
::
gridColumnBreakpoints
Define grid column breakpoints to allow the Grid Item to be responsive within its container.
- Type:
Breakpoints
- Default:
{}
/** Grid Item horizontal placenet once the viewport width is greater than or equal to the breakpoint shown below. */ interface Breakpoints { /** 640px */ mobile?: string /** 768px */ phablet?: string /** 1024px */ tablet?: string /** 1280px */ laptop?: string /** 1536px */ desktop?: string }
::grid-item
---
grid-column: "1 / 3"
grid-column-breakpoints:
mobile: "1 / 3"
phablet: "1 / 3"
tablet: "1 / span 3"
laptop: "1 / span 3"
desktop: "1 / span 4"
---
Learn, code, and build with our developer community
::
gridRow
The vertical placement of the Grid Item within its grid container. The gridRow
defines both the starting and ending positions of the item across the rows, allowing you to control how many rows the item spans.
Example:
// item will start on row 1 and ends before row 3
grid-row: "1 / 3"
// item will start on row 1 and will span 3 rows
grid-row: "1 / span 3"
- Type:
string
- Default:
'1'
::grid-item
---
grid-row: "1 / 3"
---
Learn, code, and build with our developer community
::
gridRowBreakpoints
Grid row breakpoints to make Grid Item in a container responsive.
- Type:
Breakpoints
- Default:
{}
::grid-item
---
grid-row: "1 / 3"
grid-row-breakpoints:
mobile: "1 / 3"
phablet: "1 / 3"
tablet: "1 / span 3"
laptop: "1 / span 3"
desktop: "1 / span 4"
---
Learn, code, and build with our developer community
::
Shared Props
This component also includes the shared props listed below:
padding
- default is0
.styles
- default is''
.
See here for more information on shared props.
Slots
default
Use the #default
slot to add content to the Grid Item component.
::grid-item
Learn, code, and build with our developer community
::