Skip to content

Grid2 API

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

Demos

Import

import Grid2 from '@mui/material/Grid2';
// or
import { Grid2 } from '@mui/material';

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.

The ref is forwarded to the root element.

Theme default props

You can use MuiGrid2 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
.MuiGrid2-containercontainerStyles applied to the root element if container={true}.
.MuiGrid2-rootrootStyles applied to the root element.

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.