Grid API
Demos
For examples and details on the usage of this React component, visit the component demo pages:
Import
import Grid from '@mui/material/Grid';
// or
import { Grid } from '@mui/material';
Component name
The nameMuiGrid
can be used when providing default props or style overrides in the theme.Props
Props of the native component are also available.
Name | Type | Default | Description |
---|---|---|---|
children | node | The content of the component. | |
classes | object | ||
columns | Array<number> | number | object | 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 | If a number, it sets the number of columns the grid item uses. It can't be greater than the total number of columns of the container (12 by default). If 'auto', the grid item's width matches its content. If false, the prop is ignored. If true, the grid item's width grows to use the space available in the grid container. The value is applied for the lg breakpoint and wider screens if not overridden. |
md | 'auto' | number | bool | false | If a number, it sets the number of columns the grid item uses. It can't be greater than the total number of columns of the container (12 by default). If 'auto', the grid item's width matches its content. If false, the prop is ignored. If true, the grid item's width grows to use the space available in the grid container. The value is applied for the md breakpoint and wider screens if not overridden. |
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 | If a number, it sets the number of columns the grid item uses. It can't be greater than the total number of columns of the container (12 by default). If 'auto', the grid item's width matches its content. If false, the prop is ignored. If true, the grid item's width grows to use the space available in the grid container. The value is applied for the sm breakpoint and wider screens if not overridden. |
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 | ||
wrap | 'nowrap' | 'wrap-reverse' | 'wrap' | 'wrap' | Defines the flex-wrap style property. It's applied for all screen sizes. |
xl | 'auto' | number | bool | false | If a number, it sets the number of columns the grid item uses. It can't be greater than the total number of columns of the container (12 by default). If 'auto', the grid item's width matches its content. If false, the prop is ignored. If true, the grid item's width grows to use the space available in the grid container. The value is applied for the xl breakpoint and wider screens if not overridden. |
xs | 'auto' | number | bool | false | If a number, it sets the number of columns the grid item uses. It can't be greater than the total number of columns of the container (12 by default). If 'auto', the grid item's width matches its content. If false, the prop is ignored. If true, the grid item's width grows to use the space available in the grid container. The value is applied for all the screen sizes with the lowest priority. |
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.CSS
Rule name | Global class | Description |
---|---|---|
root | .MuiGrid-root | |
container | .MuiGrid-container | |
item | .MuiGrid-item | |
zeroMinWidth | .MuiGrid-zeroMinWidth | |
direction-xs-column | .MuiGrid-direction-xs-column | |
direction-xs-column-reverse | .MuiGrid-direction-xs-column-reverse | |
direction-xs-row-reverse | .MuiGrid-direction-xs-row-reverse | |
wrap-xs-nowrap | .MuiGrid-wrap-xs-nowrap | |
wrap-xs-wrap-reverse | .MuiGrid-wrap-xs-wrap-reverse | |
spacing-xs-1 | .MuiGrid-spacing-xs-1 | |
spacing-xs-2 | .MuiGrid-spacing-xs-2 | |
spacing-xs-3 | .MuiGrid-spacing-xs-3 | |
spacing-xs-4 | .MuiGrid-spacing-xs-4 | |
spacing-xs-5 | .MuiGrid-spacing-xs-5 | |
spacing-xs-6 | .MuiGrid-spacing-xs-6 | |
spacing-xs-7 | .MuiGrid-spacing-xs-7 | |
spacing-xs-8 | .MuiGrid-spacing-xs-8 | |
spacing-xs-9 | .MuiGrid-spacing-xs-9 | |
spacing-xs-10 | .MuiGrid-spacing-xs-10 | |
grid-xs-auto | .MuiGrid-grid-xs-auto | |
grid-xs-true | .MuiGrid-grid-xs-true | |
grid-xs-1 | .MuiGrid-grid-xs-1 | |
grid-xs-2 | .MuiGrid-grid-xs-2 | |
grid-xs-3 | .MuiGrid-grid-xs-3 | |
grid-xs-4 | .MuiGrid-grid-xs-4 | |
grid-xs-5 | .MuiGrid-grid-xs-5 | |
grid-xs-6 | .MuiGrid-grid-xs-6 | |
grid-xs-7 | .MuiGrid-grid-xs-7 | |
grid-xs-8 | .MuiGrid-grid-xs-8 | |
grid-xs-9 | .MuiGrid-grid-xs-9 | |
grid-xs-10 | .MuiGrid-grid-xs-10 | |
grid-xs-11 | .MuiGrid-grid-xs-11 | |
grid-xs-12 | .MuiGrid-grid-xs-12 |
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.