Skip to main content

Grid

Grid renders a polymorphic CSS Grid container. Its convenience props map to grid templates, gaps, item alignment, and track alignment.

Open in Storybook

Import​

import { Grid } from "@tosui/react";

Basic usage​

Column patterns​

Half
Half
Sidebar (200px)
Main (flexible)
Item 1
Item 2
Item 3
Item 4

Rows​

Row 1 (100px)
Row 1 (100px)
Row 2 (200px)
Row 2 (200px)

Responsive columns and rows​

columns and rows accept responsive objects.

Item 1
Item 2
Item 3
Item 4
Item 5
Item 6

Separate row and column gaps​

Item 1
Item 2
Item 3
Item 4
Item 5
Item 6

Alignment​

1
2
3

Props reference​

All layout props (columns, rows, gap, justify, align, justifyContent, alignContent) accept responsive objects in addition to simple values.

PropTypeDefaultDescription
columnsResponsiveValue<string>-Grid template columns (CSS value)
rowsResponsiveValue<string>-Grid template rows (CSS value)
gapResponsiveValue<0-32>-Gap between grid items
gapRowResponsiveValue<0-32>-Row gap
gapColumnResponsiveValue<0-32>-Column gap
justifyResponsiveValue<"start" | "center" | "end" | "space-between" | "space-around" | "space-evenly">-Distribute tracks horizontally; takes precedence over justifyContent
alignResponsiveValue<"start" | "center" | "end" | "stretch" | "baseline">-Align items
justifyContentResponsiveValue<"start" | "center" | "end" | "space-between" | "space-around" | "space-evenly">-Distribute tracks horizontally
alignContentResponsiveValue<"start" | "center" | "end" | "space-between" | "space-around" | "space-evenly">-Distribute tracks vertically
asElementType"div"HTML element to render

TypeScript​

import { Grid, type GridProps, type GridOwnProps } from "@tosui/react";