크기
크기 (Sizing)
width와 height 유틸리티를 사용해서 요소를 부모에 상대적으로 쉽게 넓히거나 높일 수 있어요.
출처: 문서
본문
지원되는 값 (Supported values)
크기 프로퍼티들(width, height, minHeight, maxHeight, minWidth, maxWidth)은 값에 대해 다음 커스텀 변환 함수를 사용해요:
function transform(value) {
return value <= 1 && value !== 0 ? `${value * 100}%` : value;
}
값이 (0, 1] 사이면 퍼센트로 변환돼요. 그 외에는 CSS 프로퍼티에 직접 설정돼요.
```jsx
<Box sx={{ width: 1/4 }}> // Equivalent to width: '25%'
<Box sx={{ width: 300 }}> // Numbers above 1 are treated as pixel values.
<Box sx={{ width: '75%' }}> // String values are used as raw CSS.
<Box sx={{ width: 1 }}> // 100% -- numbers in the range `(0, 1]` are treated as percentage values from 0 to 100%.
너비 (Width)
```jsx
<Box sx={{ width: '25%' }}>…
<Box sx={{ width: '50%' }}>…
<Box sx={{ width: '75%' }}>…
<Box sx={{ width: '100%' }}>…
<Box sx={{ width: 'auto' }}>…
Max-width
max-width 프로퍼티는 브레이크포인트에 제약을 설정할 수 있게 해 줘요.
이 예시에서 값은 theme.breakpoints.values.md로 해석돼요.
<Box sx={{ maxWidth: 'md' }}>…
높이 (Height)
```jsx
<Box sx={{ height: '25%' }}>…
<Box sx={{ height: '50%' }}>…
<Box sx={{ height: '75%' }}>…
<Box sx={{ height: '100%' }}>…
API
import { sizing } from '@mui/system';
| Import name | Prop | CSS property | Theme key |
|---|---|---|---|
width |
width |
width |
none |
maxWidth |
maxWidth |
max-width |
theme.breakpoints.values |
minWidth |
minWidth |
min-width |
none |
height |
height |
height |
none |
maxHeight |
maxHeight |
max-height |
none |
minHeight |
minHeight |
min-height |
none |
boxSizing |
boxSizing |
box-sizing |
none |