🚀ReacUI is currently in Beta. We're actively improving it! ❣️
Grid
A flexible grid layout system built on CSS Grid with responsive capabilities
1
2
3
4
5
6
Installation
The Grid component is part of the ReacUI library. Install the package to use it in your project.
Import
Import the Grid components into your React component.
Basic Usage
The Grid component uses CSS Grid to create flexible layouts. You can specify the number of columns and gap size.
1
2
3
4
Responsive Grid
You can make a grid responsive by specifying different column counts at various breakpoints.
1
2
3
4
Grid Items
Use GridItem to control how individual items span across rows and columns of the grid.
Span 2 columns
1 column
1 column
Span 2 columns
Grid Alignment
Control how items are aligned within the grid using alignment properties.
1
2
3
API Reference
The following props are available for the Grid and GridItem components.
Grid Props
| Prop | Type | Default | Description |
|---|---|---|---|
| columns | number | 1 | Number of columns in the grid |
| gap | number | 4 | Space between grid items (in Tailwind's spacing scale) |
| rowGap | number | - | Space between rows (overrides gap for rows) |
| columnGap | number | - | Space between columns (overrides gap for columns) |
| sm | number | - | Number of columns at the small breakpoint |
| md | number | - | Number of columns at the medium breakpoint |
| lg | number | - | Number of columns at the large breakpoint |
| xl | - | - | Number of columns at the extra-large breakpoint |
| alignItems | string | 'stretch' | Vertical alignment of items: 'start', 'center', 'end', 'stretch' |
| justifyItems | string | 'start' | Horizontal alignment of items: 'start', 'center', 'end', 'stretch' |
| justifyContent | string | 'start' | Content distribution along the horizontal axis |
| alignContent | string | 'start' | Content distribution along the vertical axis |
GridItem Props
| Prop | Type | Default | Description |
|---|---|---|---|
| colSpan | number | 1 | Number of columns this item should span |
| rowSpan | number | 1 | Number of rows this item should span |
| colStart | number | - | Column start position (1-based) |
| colEnd | number | - | Column end position (inclusive) |
| rowStart | number | - | Row start position (1-based) |
| rowEnd | number | - | Row end position (inclusive) |