Grid
The Grid component provides a flexible and powerful way to create responsive layouts using CSS Flexbox.Basic usage
Container and items
A Grid can be acontainer (wraps items) or an item (defines size):
Responsive values
Specify different sizes for different breakpoints:Spacing
Control spacing between items with thespacing prop:
Row and column spacing
Control row and column spacing independently:Direction
Change the flex direction:Auto-layout
Usesize="grow" to fill available space:
size="auto" for content-based width:
Offset
Push items with theoffset prop:
Nested grids
Columns
Change the number of columns (default is 12):Props
GridProps
| Prop | Type | Default | Description |
|---|---|---|---|
children | React.ReactNode | - | The content of the component |
columns | ResponsiveStyleValue<number> | 12 | The number of columns |
columnSpacing | ResponsiveStyleValue<GridSpacing> | - | Horizontal space between items |
container | boolean | false | If true, the component will have flex container behavior |
direction | ResponsiveStyleValue<GridDirection> | 'row' | Defines flex-direction: 'row', 'row-reverse', 'column', 'column-reverse' |
offset | ResponsiveStyleValue<GridOffset> | - | Defines offset for item components: 'auto' or number |
rowSpacing | ResponsiveStyleValue<GridSpacing> | - | Vertical space between items |
size | ResponsiveStyleValue<GridSize> | - | Size of item: 'auto', 'grow', number, or false |
spacing | ResponsiveStyleValue<GridSpacing> | 0 | Space between items (both row and column) |
wrap | GridWrap | 'wrap' | Defines flex-wrap: 'nowrap', 'wrap', 'wrap-reverse' |
sx | SxProps<Theme> | - | System prop for defining custom styles |