A primitive useful for grid layouts. Grid is Box
with display: grid
and it
comes with helpful style shorthand. It renders a div
element.
display: grid
.Grid
to control the span, and start
positions within the grid.Here's an example of using grid template columns with the grid
component, and
applying a gap
or space between the grid items.
In some layouts, you may need certain grid items to span specific amount of
columns or rows instead of an even distribution. To achieve this, you need to
pass the colSpan
prop to the GridItem
component to span across columns and
also pass the rowSpan
component to span across rows. You also need to specify
the templateColumns
and templateRows
.
Pass the colStart
and colEnd
prop to GridItem
component to make an element
start or end at the nth
grid position.
Grid composes Box
so you can pass all the Box
prop, and these shorthand prop
to save you some time:
Name | Type | Description | Default |
---|---|---|---|
area | SystemProps["gridArea"] | Short hand prop for `gridArea` | - |
autoColumns | SystemProps["gridAutoColumns"] | Short hand prop for `gridAutoColumns` | - |
autoFlow | SystemProps["gridAutoFlow"] | Short hand prop for `gridAutoFlow` | - |
autoRows | SystemProps["gridAutoRows"] | Short hand prop for `gridAutoRows` | - |
column | SystemProps["gridColumn"] | Short hand prop for `gridColumn` | - |
columnGap | SystemProps["gridColumnGap"] | Short hand prop for `gridColumnGap` | - |
css | Interpolation<{}> | The emotion's css style object | - |
gap | SystemProps["gridGap"] | Short hand prop for `gridGap` | - |
row | SystemProps["gridRow"] | Short hand prop for `gridRow` | - |
rowGap | SystemProps["gridRowGap"] | Short hand prop for `gridRowGap` | - |
templateAreas | SystemProps["gridTemplateAreas"] | Short hand prop for `gridTemplateAreas` | - |
templateColumns | SystemProps["gridTemplateColumns"] | Short hand prop for `gridTemplateColumns` | - |
templateRows | SystemProps["gridTemplateRows"] | Short hand prop for `gridTemplateRows` | - |
Name | Type | Description | Default |
---|---|---|---|
colEnd | number | "auto" | ResponsiveArray<number | "auto"> | ResponsiveObject<number | "auto"> | - | |
colSpan | ResponsiveValue<number | "auto"> | The number of columns the grid item should `span`. | - |
colStart | ResponsiveValue<number | "auto"> | The column number the grid item should start. | - |
css | Interpolation<{}> | The emotion's css style object | - |
rowEnd | number | "auto" | ResponsiveArray<number | "auto"> | ResponsiveObject<number | "auto"> | - | |
rowSpan | number | "auto" | ResponsiveArray<number | "auto"> | ResponsiveObject<number | "auto"> | - | |
rowStart | number | "auto" | ResponsiveArray<number | "auto"> | ResponsiveObject<number | "auto"> | - |