Flexbox
그리드 컬럼, 내비게이션, 컴포넌트 등의 레이아웃·정렬·크기를 반응형 flexbox 유틸리티 한 세트로 빠르게 관리할 수 있어요.
출처: 문서
본문
flexbox가 처음이거나 익숙하지 않다면, 이 CSS-Tricks flexbox 가이드를 먼저 읽어 보는 걸 권해요.
부모(Parent)용 프로퍼티
display
<Box sx={{ display: 'flex' }}>…
<Box sx={{ display: 'inline-flex' }}>…
flex-direction
자세한 내용은 MDN의 flex-direction을 참고하세요.
<Box sx={{ flexDirection: 'row' }}>…
<Box sx={{ flexDirection: 'row-reverse' }}>…
<Box sx={{ flexDirection: 'column' }}>…
<Box sx={{ flexDirection: 'column-reverse' }}>…
flex-wrap
자세한 내용은 MDN의 flex-wrap을 참고하세요.
<Box sx={{ flexWrap: 'nowrap' }}>…
<Box sx={{ flexWrap: 'wrap' }}>…
<Box sx={{ flexWrap: 'wrap-reverse' }}>…
justify-content
자세한 내용은 MDN의 justify-content를 참고하세요.
<Box sx={{ justifyContent: 'flex-start' }}>…
<Box sx={{ justifyContent: 'flex-end' }}>…
<Box sx={{ justifyContent: 'center' }}>…
<Box sx={{ justifyContent: 'space-between' }}>…
<Box sx={{ justifyContent: 'space-around' }}>…
<Box sx={{ justifyContent: 'space-evenly' }}>…
align-items
자세한 내용은 MDN의 align-items를 참고하세요.
<Box sx={{ alignItems: 'flex-start' }}>…
<Box sx={{ alignItems: 'flex-end' }}>…
<Box sx={{ alignItems: 'center' }}>…
<Box sx={{ alignItems: 'stretch' }}>…
<Box sx={{ alignItems: 'baseline' }}>…
align-content
자세한 내용은 MDN의 align-content를 참고하세요.
<Box sx={{ alignContent: 'flex-start' }}>…
<Box sx={{ alignContent: 'flex-end' }}>…
<Box sx={{ alignContent: 'center' }}>…
<Box sx={{ alignContent: 'space-between' }}>…
<Box sx={{ alignContent: 'space-around' }}>…
<Box sx={{ alignContent: 'stretch' }}>…
자식(Children)용 프로퍼티
order
자세한 내용은 MDN의 order를 참고하세요.
<Box sx={{ order: 2 }}>Item 1</Box>
<Box sx={{ order: 3 }}>Item 2</Box>
<Box sx={{ order: 1 }}>Item 3</Box>
flex-grow
자세한 내용은 MDN의 flex-grow를 참고하세요.
<Box sx={{ flexGrow: 1 }}>Item 1</Box>
<Box>Item 2</Box>
<Box>Item 3</Box>
flex-shrink
자세한 내용은 MDN의 flex-shrink를 참고하세요.
<Box sx={{ width: '100%' }}>Item 1</Box>
<Box sx={{ flexShrink: 1 }}>Item 2</Box>
<Box sx={{ flexShrink: 0 }}>Item 3</Box>
align-self
자세한 내용은 MDN의 align-self를 참고하세요.
<Box>Item 1</Box>
<Box sx={{ alignSelf: 'flex-end' }}>Item 2</Box>
<Box>Item 3</Box>
API
import { flexbox } from '@mui/system';
| Import name | Prop | CSS property | Theme key |
|---|---|---|---|
flexDirection |
flexDirection |
flex-direction |
none |
flexWrap |
flexWrap |
flex-wrap |
none |
justifyContent |
justifyContent |
justify-content |
none |
alignItems |
alignItems |
align-items |
none |
alignContent |
alignContent |
align-content |
none |
order |
order |
order |
none |
flex |
flex |
flex |
none |
flexGrow |
flexGrow |
flex-grow |
none |
flexShrink |
flexShrink |
flex-shrink |
none |
alignSelf |
alignSelf |
align-self |
none |