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 |
12 | The number of columns. |
columnSpacing | Array<number | string> | number | object | string | - | Defines the horizontal space between the type item components. It overrides the value of the spacing prop. |
component | elementType | - | - |
container | bool | false | If true , the component will have the flex container behavior. You should be wrapping items with a container. |
direction | ‘column-reverse’ | ‘column’ | ‘row-reverse’ | ‘row’ | Array<‘column-reverse’ | ‘column’ | ‘row-reverse’ | ‘row’> | object | ‘row’ | Defines the flex-direction style property. It is applied for all screen sizes. |
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 item components. It overrides the value of the spacing prop. |
sm | ‘auto’ | number | bool | false | - |
spacing | Array<number | string> | number | object | string | 0 | Defines the space between the type item components. It can only be used on a type container component. |
sx | Array<func | object | bool> | func | object | - | See the sx page for more details. |
wrap | ‘nowrap’ | ‘wrap-reverse’ | ‘wrap’ | ‘wrap’ | Defines the flex-wrap style property. It’s applied for all screen sizes. |
xl | ‘auto’ | number | bool | false | - |
xs | ‘auto’ | number | bool | false | - |
zeroMinWidth | bool | false | - |
As a CSS utility, the Grid component also supports all system
properties. You can use them as props directly on the component.
The ref
is forwarded to the root element.
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 to .MuiGrid-grid-xs-12 | grid-xs-* | Grid size classes |
.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 to .MuiGrid-spacing-xs-10 | spacing-xs-* | Spacing classes |
.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:
styleOverrides
property in a custom theme.If you did not find the information in this page, consider having a look at the implementation of the component for more detail.