Skip to content

Grid

Grid provides a friendly interface to create responsive grid layouts with ease.

Grid Root Props:templateColumns="repeat(2, 1fr)" gap="1rem"
Row 1
Column 1
Row 1
Column 2
Row 2
Column 1
Row 2
Column 2
Grid Root Props:templateColumns="1fr 2fr 1fr" gap="2rem"
Column
Column
Column
Grid Root Props:templateColumns="repeat(4, 1fr)" gap="1rem"
Single column
Spans 3 columns
Spans 2 columns
Single column
Single column
import { Grid } from '@fintech-sandpit/ui/react';
return (
<Grid.Root
templateColumns="repeat(2, 1fr)"
gap="1rem"
>
<Grid.Cell>
Row 1 / Column 1
</Grid.Cell>
<Grid.Cell>
Row 1 / Column 2
</Grid.Cell>
<Grid.Cell>
Row 2 / Column 1
</Grid.Cell>
<Grid.Cell>
Row 2 / Column 2
</Grid.Cell>
</Grid.Root>
);
import { Grid } from '@fintech-sandpit/ui/react';
return (
<Grid.Root
templateColumns="repeat(3, 1fr)"
gap="1rem"
>
<Grid.Cell>
Item 1
</Grid.Cell>
<Grid.Cell>
Item 2
</Grid.Cell>
<Grid.Cell>
Item 3
</Grid.Cell>
</Grid.Root>
);
import { Grid } from '@fintech-sandpit/ui/react';
return (
<Grid.Root
templateColumns="repeat(4, 1fr)"
gap="1rem"
>
<Grid.Cell>
Single column
</Grid.Cell>
<Grid.Cell colSpan={3}>
Spans 3 columns
</Grid.Cell>
<Grid.Cell colSpan={2}>
Spans 2 columns
</Grid.Cell>
<Grid.Cell>
Single column
</Grid.Cell>
<Grid.Cell>
Single column
</Grid.Cell>
</Grid.Root>
);
NameTypeRequiredDefaultDescription
templateColumnsstringDefines the columns of the grid 1
templateRowsstringDefines the rows of the grid 2
autoFlowGridAutoFlow'row'Direction of auto-placed items 3
columnsnumberNumber of columns in the grid 4
rowsnumberNumber of rows in the grid 5
gapCssUnitGap between grid items
  1. See the MDN docs
  2. See the MDN docs
  3. See the MDN docs
  4. Use instead of templateColumns when you want to use a fixed number of columns
  5. Use instead of templateRows when you want to use a fixed number of rows
NameTypeRequiredDefaultDescription
colSpannumberNumber of columns the item should span 1
rowSpannumberNumber of rows the item should span 1
asChildbooleanfalseWhether to render the item as a child component
  1. Non-numerical values, and values less than 1 are ignored
type CssUnit = `${number}${'em' | 'px' | 'rem' | 'vh' | 'vw' | '%'}`
type GridAutoFlow = 'row' | 'column' | 'dense' | 'row dense' | 'column dense'