Density
Density (밀도)
Material UI 컴포넌트에 밀도를 적용하는 방법.
출처: 문서
본문
밀도 적용하기 (Applying density)
이 섹션은 밀도를 적용하는 방법을 설명합니다. 애플리케이션에서 밀도를 사용하는 잠재적 사용 사례나 고려 사항은 다루지 않습니다. Material Design 가이드라인에는 이러한 주제를 더 자세히 다루는 종합 가이드가 있습니다.
밀도 구현하기 (Implementing density)
일부 컴포넌트는 props를 통해 더 높은 밀도를 적용할 수 있습니다. 컴포넌트 페이지에는 각 컴포넌트를 더 높은 밀도로 적용한 예시가 최소한 하나씩 있습니다.
컴포넌트에 따라 밀도는 더 낮은 스페이싱(spacing)을 통해 적용되거나, 단순히 크기를 줄여서 적용됩니다.
더 높은 밀도를 적용하는 props가 있는 컴포넌트는 다음과 같습니다:
- Button
- Fab
- FilledInput
- FormControl
- FormHelperText
- IconButton
- InputBase
- InputLabel
- ListItem
- OutlinedInput
- Table
- TextField
- Toolbar
테마 밀도 탐색하기 (Explore theme density)
이 도구를 사용하면 스페이싱과 컴포넌트 props를 통해 밀도를 적용할 수 있습니다. 주변을 탐색하며 이것이 Material UI 컴포넌트의 전체적인 느낌에 어떻게 적용되는지 확인할 수 있습니다.
높은 밀도를 활성화하면 문서에 커스텀 테마가 적용됩니다. 이 테마는 데모 목적으로만 사용됩니다. 이 테마를 애플리케이션 전체에 적용해서는 안 됩니다. 사용자 경험에 부정적인 영향을 줄 수 있기 때문입니다. Material Design 가이드라인에는 밀도를 적용해서는 안 되는 경우에 대한 예시가 있습니다.
테마는 다음 옵션으로 구성됩니다:
const theme = createTheme({
components: {
MuiButton: {
defaultProps: {
size: 'small',
},
},
MuiFilledInput: {
defaultProps: {
margin: 'dense',
},
},
MuiFormControl: {
defaultProps: {
margin: 'dense',
},
},
MuiFormHelperText: {
defaultProps: {
margin: 'dense',
},
},
MuiIconButton: {
defaultProps: {
size: 'small',
},
},
MuiInputBase: {
defaultProps: {
margin: 'dense',
},
},
MuiInputLabel: {
defaultProps: {
margin: 'dense',
},
},
MuiListItem: {
defaultProps: {
dense: true,
},
},
MuiOutlinedInput: {
defaultProps: {
margin: 'dense',
},
},
MuiFab: {
defaultProps: {
size: 'small',
},
},
MuiTable: {
defaultProps: {
size: 'small',
},
},
MuiTextField: {
defaultProps: {
margin: 'dense',
},
},
MuiToolbar: {
defaultProps: {
variant: 'dense',
},
},
},
});
{{"demo": "DensityTool.js", "hideToolbar": true}}