Grid

Grid

import Grid from "@kiwicom/orbit-components/lib/utils/Grid";
<Grid columns="4fr minmax(256px, 1fr)">
// You can use your custom components
<Section>Hello world!</Section>
<SideBar>I'm content on the right side.</SideBar>
</Grid>

Props

NameTypeDefaultDescription
childrenReact.NodeThe content of the Grid. See Usage
classNamestringIf needed, you can extend the Grid component with styled and add your own styles.
columnsstring"1fr"Property alias for grid-template-columns.
columnGapstringGap size for columns.
dataTeststringOptional prop for testing purposes.
desktopObjectObject for properties for desktop viewports. See Media queries
asstring"div"The valid DOM element used for the root node.
gapstringGap size for columns and rows.
inlinebooleanfalseIf true, the Grid will have display: inline-grid; otherwise it will be display: grid.
tabletObjectObject for setting up properties for tablet viewports. See Media queries
largeDesktopObjectObject for setting up properties for largeDesktop viewports. See Media queries
largeMobileObjectObject for setting up properties for largeMobile viewports. See Media queries
maxWidthstringAlias for the max-width property of the Grid component.
mediumMobileObjectObject for setting up properties for mediumMobile viewports. See Media queries
rowsstring"1fr"Property alias for grid-template-rows.
rowGapstringThe gap size for rows.
widthstringAlias for the width property of the Grid component.
spaceAfterenumAdditional padding to bottom of the Stack.

Media Queries

NameTypeDefaultDescription
columnsstring"none"Property alias for grid-template-columns.
columnGapstringGap size for columns.
gapstringGap size for columns and rows.
inlinebooleanfalseIf true, the grid will have display: inline-grid; otherwise display: grid.
maxWidthstringAlias for the max-width property of the Grid component.
rowsstring"none"Property alias for grid-template-rows.
rowGapstringGap size for rows.
widthstringAlias for the width property of the Grid component.
spaceAfterenumAdditional padding to bottom of the Stack.

enum

spaceAfter
"none"
"smallest"
"small"
"normal"
"medium"
"large"
"largest"

Why you should use this component

  • Compiling the repeat function to the old specification
  • Auto-placement of its children

Usage

import Grid from "@kiwicom/orbit-components/lib/utils/Grid";
// your custom component to fill each cell in the grid
import Cell from "./Cell";
const Example = () => (
<Grid columns="1fr 1fr" rows="1fr 1fr">
<Cell>First column, first row</Cell>
<Cell>Second column, first row</Cell>
<Cell>First column, second row</Cell>
<Cell>Second column, second row</Cell>
</Grid>
);