Skip to content

Grid API

API reference docs for the React Grid component. Learn about the props, CSS, and other APIs of this exported module.

Component 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

Props of the native component are also available.

children

The content of the component.

Type:node


classes

See CSS API below for more details.

Type:object


columns

The number of columns.

Type:Array<number>
| number
| object

Default:12


columnSpacing

Defines the horizontal space between the type item components. It overrides the value of the spacing prop.

Type:Array<number
| string>
| number
| object
| string


component

Type:elementType


container

If true, the component will have the flex container behavior. You should be wrapping items with a container.

Type:bool

Default:false


direction

Defines the flex-direction style property. It is applied for all screen sizes.

Type:'column-reverse'
| 'column'
| 'row-reverse'
| 'row'
| Array<'column-reverse'
| 'column'
| 'row-reverse'
| 'row'>
| object

Default:'row'


item

Type:bool

Default:false


lg

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.

Type:'auto'
| number
| bool

Default:false


md

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.

Type:'auto'
| number
| bool

Default:false


rowSpacing

Defines the vertical space between the type item components. It overrides the value of the spacing prop.

Type:Array<number
| string>
| number
| object
| string


sm

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.

Type:'auto'
| number
| bool

Default:false


spacing

Defines the space between the type item components. It can only be used on a type container component.

Type:Array<number
| string>
| number
| object
| string

Default:0


sx

See the `sx` page for more details.

Type:Array<func
| object
| bool>
| func
| object


wrap

Defines the flex-wrap style property. It's applied for all screen sizes.

Type:'nowrap'
| 'wrap-reverse'
| 'wrap'

Default:'wrap'


xl

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.

Type:'auto'
| number
| bool

Default:false


xs

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.

Type:'auto'
| number
| bool

Default:false


zeroMinWidth

Type:bool

Default: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.

Theme default props

You can use MuiGrid to change the default props of this component with the theme.


CSS classes

These class names are useful for styling with CSS. They are applied to the component's slots when specific states are triggered.

.MuiGrid-container

Styles applied to the root element if container={true}.

Rule name:container


.MuiGrid-direction-xs-column

Styles applied to the root element if direction="column".

Rule name:direction-xs-column


.MuiGrid-direction-xs-column-reverse

Styles applied to the root element if direction="column-reverse".

Rule name:direction-xs-column-reverse


.MuiGrid-direction-xs-row-reverse

Styles applied to the root element if direction="row-reverse".

Rule name:direction-xs-row-reverse


.MuiGrid-grid-xs-1

Rule name:grid-xs-1


.MuiGrid-grid-xs-10

Rule name:grid-xs-10


.MuiGrid-grid-xs-11

Rule name:grid-xs-11


.MuiGrid-grid-xs-12

Rule name:grid-xs-12


.MuiGrid-grid-xs-2

Rule name:grid-xs-2


.MuiGrid-grid-xs-3

Rule name:grid-xs-3


.MuiGrid-grid-xs-4

Rule name:grid-xs-4


.MuiGrid-grid-xs-5

Rule name:grid-xs-5


.MuiGrid-grid-xs-6

Rule name:grid-xs-6


.MuiGrid-grid-xs-7

Rule name:grid-xs-7


.MuiGrid-grid-xs-8

Rule name:grid-xs-8


.MuiGrid-grid-xs-9

Rule name:grid-xs-9


.MuiGrid-grid-xs-auto

Rule name:grid-xs-auto


.MuiGrid-grid-xs-true

Rule name:grid-xs-true


.MuiGrid-item

Styles applied to the root element if `item={true}`.

Rule name:item


.MuiGrid-root

Styles applied to the root element.

Rule name:root


.MuiGrid-spacing-xs-1

Rule name:spacing-xs-1


.MuiGrid-spacing-xs-10

Rule name:spacing-xs-10


.MuiGrid-spacing-xs-2

Rule name:spacing-xs-2


.MuiGrid-spacing-xs-3

Rule name:spacing-xs-3


.MuiGrid-spacing-xs-4

Rule name:spacing-xs-4


.MuiGrid-spacing-xs-5

Rule name:spacing-xs-5


.MuiGrid-spacing-xs-6

Rule name:spacing-xs-6


.MuiGrid-spacing-xs-7

Rule name:spacing-xs-7


.MuiGrid-spacing-xs-8

Rule name:spacing-xs-8


.MuiGrid-spacing-xs-9

Rule name:spacing-xs-9


.MuiGrid-wrap-xs-nowrap

Styles applied to the root element if wrap="nowrap".

Rule name:wrap-xs-nowrap


.MuiGrid-wrap-xs-wrap-reverse

Styles applied to the root element if wrap="reverse".

Rule name:wrap-xs-wrap-reverse


.MuiGrid-zeroMinWidth

Styles applied to the root element if `zeroMinWidth={true}`.

Rule name:zeroMinWidth



You can override the style of the component using one of these customization options: