Pular para o conteúdo

Grid API

Documentação da API para o componente React Grid . Aprenda sobre as propriedades disponíveis e a API CSS.

Importação

import Grid from '@mui/material/Grid';
// ou
import { Grid } from '@mui/material';
Você pode aprender sobre a diferença lendo este guia sobre como minimizar o tamanho do pacote.

Nome do componente

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

Propriedades

Props of the nativo component are also available.

NomeTipoPadrãoDescrição
childrennode
O conteúdo do componente.
classesobject
Sobrescreve ou extende os estilos aplicados para o componente. Veja a API CSS abaixo para maiores detalhes.
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'
| 1
| 2
| 3
| 4
| 5
| 6
| 7
| 8
| 9
| 10
| 11
| 12
| bool
false
Defines 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
false
Defines the number of grids the component is going to use. It's 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'
| 1
| 2
| 3
| 4
| 5
| 6
| 7
| 8
| 9
| 10
| 11
| 12
| bool
false
Defines the number of grids the component is going to use. It's 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.
sxfunc
| 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'
| 1
| 2
| 3
| 4
| 5
| 6
| 7
| 8
| 9
| 10
| 11
| 12
| bool
false
Defines 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
false
Defines the number of grids the component is going to use. It's 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.

As a CSS utility, the Grid component also supports all system properties. You can use them as props directly on the component.

O ref é encaminhado para o elemento raiz.

CSS

Nome da regraClasse globalDescrição
root.MuiGrid-rootEstilos aplicados ao elemento raiz.
container.MuiGrid-containerEstilos aplicados para o elemento raiz se container={true}.
item.MuiGrid-itemEstilos aplicados para o elemento raiz se item={true}.
zeroMinWidth.MuiGrid-zeroMinWidthEstilos aplicados para o elemento raiz se zeroMinWidth={true}.
direction-xs-column.MuiGrid-direction-xs-columnEstilos aplicados para o elemento raiz se direction="column".
direction-xs-column-reverse.MuiGrid-direction-xs-column-reverseEstilos aplicados para o elemento raiz se direction="column-reverse".
direction-xs-row-reverse.MuiGrid-direction-xs-row-reverseEstilos aplicados para o elemento raiz se direction="row-reverse".
wrap-xs-nowrap.MuiGrid-wrap-xs-nowrapEstilos aplicados para o elemento raiz se wrap="nowrap".
wrap-xs-wrap-reverse.MuiGrid-wrap-xs-wrap-reverseEstilos aplicados para o elemento raiz se wrap="reverse".
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

Você pode sobrescrever o estilo do componente usando uma dessas opções de customização:

Demonstrações