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.

Demos

Import

import Grid from '@mui/system/Grid';
// or
import { Grid } from '@mui/system';

Learn about the difference by reading this guide on minimizing bundle size.

Props

Props of the native component are also available.

NameTypeDefaultDescription
childrennode-

The content of the component.

columnsArray<number>
| number
| object
12

The number of columns.

columnSpacingArray<number
| string>
| number
| object
| string
-

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

containerboolfalse

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.

offsetstring
| number
| Array<string
| number>
| object
-

Defines the offset value for the type item components.

rowSpacingArray<number
| string>
| number
| object
| string
-

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

sizestring
| bool
| number
| Array<string
| bool
| number>
| object
-

Defines the size of the the type item components.

spacingArray<number
| string>
| number
| object
| string
0

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

wrap'nowrap'
| 'wrap-reverse'
| 'wrap'
'wrap'

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

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.

Class nameRule nameDescription
.MuiGrid-containercontainerStyles applied to the root element if container={true}.
.MuiGrid-direction-xs-columndirection-xs-columnStyles applied to the root element if direction="column".
.MuiGrid-direction-xs-column-reversedirection-xs-column-reverseStyles applied to the root element if direction="column-reverse".
.MuiGrid-direction-xs-row-reversedirection-xs-row-reverseStyles applied to the root element if direction="row-reverse".
.MuiGrid-rootrootStyles applied to the root element.
.MuiGrid-wrap-xs-nowrapwrap-xs-nowrapStyles applied to the root element if wrap="nowrap".
.MuiGrid-wrap-xs-wrap-reversewrap-xs-wrap-reverseStyles applied to the root element if wrap="reverse".

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

Source code

If you did not find the information in this page, consider having a look at the implementation of the component for more detail.