Перейти к контенту

Grid API

API documentation for the React Grid component. Learn about the available props, and the CSS API.

Import

import Grid from '@material-ui/core/Grid';
// or
import { Grid } from '@material-ui/core';
You can learn about the difference by reading this guide on minimizing bundle size.

Component name

The name MuiGrid can be used when providing default props or style overrides in the theme.

Props

NameTypeDefaultDescription
alignContent'center'
| 'flex-end'
| 'flex-start'
| 'space-around'
| 'space-between'
| 'stretch'
'stretch'Defines the align-content style property. It's applied for all screen sizes.
alignItems'baseline'
| 'center'
| 'flex-end'
| 'flex-start'
| 'stretch'
'stretch'Defines the align-items style property. It's applied for all screen sizes.
childrennodeThe content of the component.
classesobjectOverride or extend the styles applied to the component. See CSS API below for more details.
componentelementTypeThe component used for the root node. Either a string to use a HTML element or a component.
containerboolfalseIf true, the component will have the flex container behavior. You should be wrapping items with a container.
direction'column-reverse'
| 'column'
| 'row-reverse'
| 'row'
'row'Defines the flex-direction style property. It is applied for all screen sizes.
itemboolfalseIf true, the component will have the flex item behavior. You should be wrapping items with a container.
justifyContent'center'
| 'flex-end'
| 'flex-start'
| 'space-around'
| 'space-between'
| 'space-evenly'
'flex-start'Defines the justify-content style property. It is applied for all screen sizes.
lg'auto'
| 1
| 2
| 3
| 4
| 5
| 6
| 7
| 8
| 9
| 10
| 11
| 12
| bool
falseDefines the number of grids the component is going to use. It's applied for the lg breakpoint and wider screens if not overridden.
md'auto'
| 1
| 2
| 3
| 4
| 5
| 6
| 7
| 8
| 9
| 10
| 11
| 12
| bool
falseDefines the number of grids the component is going to use. It's applied for the md breakpoint and wider screens if not overridden.
sm'auto'
| 1
| 2
| 3
| 4
| 5
| 6
| 7
| 8
| 9
| 10
| 11
| 12
| bool
falseDefines the number of grids the component is going to use. It's applied for the sm breakpoint and wider screens if not overridden.
spacing0
| 1
| 2
| 3
| 4
| 5
| 6
| 7
| 8
| 9
| 10
0Defines the space between the type item component. 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.
xl'auto'
| 1
| 2
| 3
| 4
| 5
| 6
| 7
| 8
| 9
| 10
| 11
| 12
| bool
falseDefines the number of grids the component is going to use. It's applied for the xl breakpoint and wider screens.
xs'auto'
| 1
| 2
| 3
| 4
| 5
| 6
| 7
| 8
| 9
| 10
| 11
| 12
| bool
falseDefines the number of grids the component is going to use. It's applied for all the screen sizes with the lowest priority.
zeroMinWidthboolfalseIf 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.
Any other props supplied will be provided to the root element (native element).

CSS

Rule nameGlobal classDescription
root.MuiGrid-rootStyles applied to the root element.
container.MuiGrid-containerStyles applied to the root element if container={true}.
item.MuiGrid-itemStyles applied to the root element if item={true}.
zeroMinWidth.MuiGrid-zeroMinWidthStyles applied to the root element if zeroMinWidth={true}.
direction-xs-column.MuiGrid-direction-xs-columnStyles applied to the root element if direction="column".
direction-xs-column-reverse.MuiGrid-direction-xs-column-reverseStyles applied to the root element if direction="column-reverse".
direction-xs-row-reverse.MuiGrid-direction-xs-row-reverseStyles applied to the root element if direction="row-reverse".
wrap-xs-nowrap.MuiGrid-wrap-xs-nowrapStyles applied to the root element if wrap="nowrap".
wrap-xs-wrap-reverse.MuiGrid-wrap-xs-wrap-reverseStyles applied to the root element if wrap="reverse".
align-items-xs-center.MuiGrid-align-items-xs-centerStyles applied to the root element if alignItems="center".
align-items-xs-flex-start.MuiGrid-align-items-xs-flex-startStyles applied to the root element if alignItems="flex-start".
align-items-xs-flex-end.MuiGrid-align-items-xs-flex-endStyles applied to the root element if alignItems="flex-end".
align-items-xs-baseline.MuiGrid-align-items-xs-baselineStyles applied to the root element if alignItems="baseline".
align-content-xs-center.MuiGrid-align-content-xs-centerStyles applied to the root element if alignContent="center".
align-content-xs-flex-start.MuiGrid-align-content-xs-flex-startStyles applied to the root element if alignContent="flex-start".
align-content-xs-flex-end.MuiGrid-align-content-xs-flex-endStyles applied to the root element if alignContent="flex-end".
align-content-xs-space-between.MuiGrid-align-content-xs-space-betweenStyles applied to the root element if alignContent="space-between".
align-content-xs-space-around.MuiGrid-align-content-xs-space-aroundStyles applied to the root element if alignContent="space-around".
justify-content-xs-center.MuiGrid-justify-content-xs-centerStyles applied to the root element if justifyContent="center".
justify-content-xs-flex-end.MuiGrid-justify-content-xs-flex-endStyles applied to the root element if justifyContent="flex-end".
justify-content-xs-space-between.MuiGrid-justify-content-xs-space-betweenStyles applied to the root element if justifyContent="space-between".
justify-content-xs-space-around.MuiGrid-justify-content-xs-space-aroundStyles applied to the root element if justifyContent="space-around".
justify-content-xs-space-evenly.MuiGrid-justify-content-xs-space-evenlyStyles applied to the root element if justifyContent="space-evenly".
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: If that isn't sufficient, you can check the implementation of the component for more detail.

Demos