본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

Grid API

원문 보기 위키 갱신

Grid API (그리드 API)

Grid는 화면을 그리드로 분할해 레이아웃을 구성하는 컴포넌트예요. 이 페이지에서는 이 컴포넌트의 props, CSS 클래스, 그리고 기타 API를 하나씩 설명해 드릴게요.

출처: 문서

본문

데모 (Demos)

이 React 컴포넌트의 사용법과 세부 사항은 컴포넌트 데모 페이지에서 확인할 수 있어요.

  • Grid

Import

import Grid from '@mui/material/Grid';
// 또는
import { Grid } from '@mui/material';

번들 크기를 줄이는 방법이 궁금하시다면, 이 차이에 대한 가이드 문서를 읽어 보시면 좋아요.

Props

네이티브 컴포넌트의 props도 그대로 사용할 수 있어요.

Name Type Default Description
children node - The content of the component.
columns Array<number>| number| object 12 The number of columns.
columnSpacing Array<number| string>| number| object| string - Defines the horizontal space between the type item components. It overrides the value of the spacing prop.
container bool false If true, the component will have the flex container behavior. You should be wrapping items with a container.
direction 'row-reverse'| 'row'| Array<'row-reverse'| 'row'>| object 'row' Defines the flex-direction style property for the container. ⚠️ Only row and row-reverse are supported. column and column-reverse are not supported, because the Grid component is designed to subdivide layouts into columns, not rows. For vertical layouts, use Stack instead.
offset string| number| Array<string| number>| object - Defines the offset value for the type item components.
rowSpacing Array<number| string>| number| object| string - Defines the vertical space between the type item components. It overrides the value of the spacing prop.
size string| bool| number| Array<string| bool| number>| object - Defines the size of the the type item components.
spacing Array<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.

ref는 루트 요소로 전달돼요.

테마 기본 props (Theme default props)

MuiGrid를 사용하면 테마를 통해 이 컴포넌트의 기본 props를 바꿀 수 있어요.

CSS 클래스 (CSS classes)

이 클래스들은 CSS로 스타일을 지정할 때 유용해요. 특정 상태가 트리거되면 컴포넌트의 슬롯에 적용돼요.

Class name Rule name Description
.MuiGrid-container container Styles applied to the root element if container={true}.
.MuiGrid-root root Styles applied to the root element.

컴포넌트의 스타일을 다음 방법 중 하나로 재정의할 수 있어요.

  • 전역 클래스 이름으로 재정의하기
  • 커스텀 테마의 컴포넌트 styleOverrides 속성에 규칙 이름(rule name)으로 재정의하기

소스 코드 (Source code)

이 페이지에서 원하는 정보를 찾지 못했다면, 컴포넌트의 구현 코드를 살펴보시면 더 자세한 내용을 확인할 수 있어요.

더 알아보기