Grid API
API reference docs for the React Grid component. Learn about the props, CSS, and other APIs of this exported module.
Demos
Import
import Grid from '@mui/material/Grid';
// or
import { Grid } from '@mui/material';
Learn about the difference by reading this guide on minimizing bundle size.
Props of the native component are also available.
Name | Type | Default | Description |
---|---|---|---|
children | node | - | The content of the component. |
classes | object | - | See CSS classes API below for more details. |
columns | Array<number> | number | object | 12 | The number of columns. |
columnSpacing | Array<number | string> | number | object | string | - | Defines the horizontal space between the type |
component | elementType | - | |
container | bool | false | If |
direction | 'column-reverse' | 'column' | 'row-reverse' | 'row' | Array<'column-reverse' | 'column' | 'row-reverse' | 'row'> | object | 'row' | Defines the |
item | bool | false | |
lg | 'auto' | number | bool | false | |
md | 'auto' | number | bool | false | |
rowSpacing | Array<number | string> | number | object | string | - | Defines the vertical space between the type |
sm | 'auto' | number | bool | false | |
spacing | Array<number | string> | number | object | string | 0 | Defines the space between the type |
sx | Array<func | object | bool> | func | object | - | See the `sx` page for more details. |
wrap | 'nowrap' | 'wrap-reverse' | 'wrap' | 'wrap' | Defines the |
xl | 'auto' | number | bool | false | |
xs | 'auto' | number | bool | false | |
zeroMinWidth | bool | false |
system
properties. You can use them as props directly on the component.ref
is forwarded to the root element.Theme default props
You can use MuiGrid
to change the default props of this component with the theme.
These class names are useful for styling with CSS. They are applied to the component's slots when specific states are triggered.
Class name | Rule name | Description |
---|---|---|
.MuiGrid-container | container | Styles applied to the root element if container={true} . |
.MuiGrid-direction-xs-column | direction-xs-column | Styles applied to the root element if direction="column" . |
.MuiGrid-direction-xs-column-reverse | direction-xs-column-reverse | Styles applied to the root element if direction="column-reverse" . |
.MuiGrid-direction-xs-row-reverse | direction-xs-row-reverse | Styles applied to the root element if direction="row-reverse" . |
.MuiGrid-grid-xs-1 | grid-xs-1 | |
.MuiGrid-grid-xs-10 | grid-xs-10 | |
.MuiGrid-grid-xs-11 | grid-xs-11 | |
.MuiGrid-grid-xs-12 | grid-xs-12 | |
.MuiGrid-grid-xs-2 | grid-xs-2 | |
.MuiGrid-grid-xs-3 | grid-xs-3 | |
.MuiGrid-grid-xs-4 | grid-xs-4 | |
.MuiGrid-grid-xs-5 | grid-xs-5 | |
.MuiGrid-grid-xs-6 | grid-xs-6 | |
.MuiGrid-grid-xs-7 | grid-xs-7 | |
.MuiGrid-grid-xs-8 | grid-xs-8 | |
.MuiGrid-grid-xs-9 | grid-xs-9 | |
.MuiGrid-grid-xs-auto | grid-xs-auto | |
.MuiGrid-grid-xs-true | grid-xs-true | |
.MuiGrid-item | item | Styles applied to the root element if `item={true}`. |
.MuiGrid-root | root | Styles applied to the root element. |
.MuiGrid-spacing-xs-1 | spacing-xs-1 | |
.MuiGrid-spacing-xs-10 | spacing-xs-10 | |
.MuiGrid-spacing-xs-2 | spacing-xs-2 | |
.MuiGrid-spacing-xs-3 | spacing-xs-3 | |
.MuiGrid-spacing-xs-4 | spacing-xs-4 | |
.MuiGrid-spacing-xs-5 | spacing-xs-5 | |
.MuiGrid-spacing-xs-6 | spacing-xs-6 | |
.MuiGrid-spacing-xs-7 | spacing-xs-7 | |
.MuiGrid-spacing-xs-8 | spacing-xs-8 | |
.MuiGrid-spacing-xs-9 | spacing-xs-9 | |
.MuiGrid-wrap-xs-nowrap | wrap-xs-nowrap | Styles applied to the root element if wrap="nowrap" . |
.MuiGrid-wrap-xs-wrap-reverse | wrap-xs-wrap-reverse | Styles applied to the root element if wrap="reverse" . |
.MuiGrid-zeroMinWidth | zeroMinWidth | Styles applied to the root element if `zeroMinWidth={true}`. |
You can override the style of the component using one of these customization options:
- With a global class name.
- With a rule name as part of the component's
styleOverrides
property in a custom theme.