Skip to content
Skip to content

GridLegacy API

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

Demos

Import

import GridLegacy from '@mui/material/GridLegacy';
// or
import { GridLegacy } 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.

classesobject-

Override or extend the styles applied to the component.

See CSS classes API below for more details.

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.

componentelementType-

The component used for the root node. Either a string to use a HTML element or a component.

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.

itemboolfalse

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

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.

rowSpacingArray<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.

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.

sxArray<func
| object
| bool>
| func
| object
-

The system prop that allows defining system overrides as well as additional CSS styles.

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

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.

zeroMinWidthboolfalse

If true, it sets min-width: 0 on the item. Refer to the limitations section of the documentation to better understand the use case.

The ref is forwarded to the root element.

Theme default props

You can use MuiGridLegacy 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
.MuiGridLegacy-containercontainerStyles applied to the root element if container={true}.
.MuiGridLegacy-direction-xs-columndirection-xs-columnStyles applied to the root element if direction="column".
.MuiGridLegacy-direction-xs-column-reversedirection-xs-column-reverseStyles applied to the root element if direction="column-reverse".
.MuiGridLegacy-direction-xs-row-reversedirection-xs-row-reverseStyles applied to the root element if direction="row-reverse".
.MuiGridLegacy-grid-xs-1grid-xs-1
.MuiGridLegacy-grid-xs-10grid-xs-10
.MuiGridLegacy-grid-xs-11grid-xs-11
.MuiGridLegacy-grid-xs-12grid-xs-12
.MuiGridLegacy-grid-xs-2grid-xs-2
.MuiGridLegacy-grid-xs-3grid-xs-3
.MuiGridLegacy-grid-xs-4grid-xs-4
.MuiGridLegacy-grid-xs-5grid-xs-5
.MuiGridLegacy-grid-xs-6grid-xs-6
.MuiGridLegacy-grid-xs-7grid-xs-7
.MuiGridLegacy-grid-xs-8grid-xs-8
.MuiGridLegacy-grid-xs-9grid-xs-9
.MuiGridLegacy-grid-xs-autogrid-xs-auto
.MuiGridLegacy-grid-xs-truegrid-xs-true
.MuiGridLegacy-itemitemStyles applied to the root element if item={true}.
.MuiGridLegacy-rootrootStyles applied to the root element.
.MuiGridLegacy-spacing-xs-1spacing-xs-1
.MuiGridLegacy-spacing-xs-10spacing-xs-10
.MuiGridLegacy-spacing-xs-2spacing-xs-2
.MuiGridLegacy-spacing-xs-3spacing-xs-3
.MuiGridLegacy-spacing-xs-4spacing-xs-4
.MuiGridLegacy-spacing-xs-5spacing-xs-5
.MuiGridLegacy-spacing-xs-6spacing-xs-6
.MuiGridLegacy-spacing-xs-7spacing-xs-7
.MuiGridLegacy-spacing-xs-8spacing-xs-8
.MuiGridLegacy-spacing-xs-9spacing-xs-9
.MuiGridLegacy-wrap-xs-nowrapwrap-xs-nowrapStyles applied to the root element if wrap="nowrap".
.MuiGridLegacy-wrap-xs-wrap-reversewrap-xs-wrap-reverseStyles applied to the root element if wrap="reverse".
.MuiGridLegacy-zeroMinWidthzeroMinWidthStyles applied to the root element if zeroMinWidth={true}.

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.