Shape
Shape는 컴포넌트의 border radius(테두리 둥글기)를 제어하는 데 쓰는 디자인 토큰이에요.
출처: 문서
본문
shape는 borderRadius 하나의 속성을 담고 있고, 기본값은 4px예요. 여러 컴포넌트가 이 값을 사용해서 라이브러리 전체에서 일관된 border radius를 유지해요.
커스텀 shape
커스텀 shape를 추가하려면 shape 키를 가진 테마를 만들어 주세요.
import { createTheme } from '@mui/material/styles';
const theme = createTheme({
shape: {
borderRadius: 8,
borderRadiusSm: 4, // new property
borderRadiusMd: 8, // new property
borderRadiusLg: 16, // new property
borderRadiusXl: 24, // new property
},
});
TypeScript
TypeScript를 사용한다면 모듈 증강(module augmentation)을 통해 새로운 shape 속성들을 테마에 확장해야 해요.
declare module '@mui/material/styles' {
interface Shape {
borderRadiusSm: number;
borderRadiusMd: number;
borderRadiusLg: number;
borderRadiusXl: number;
}
interface ShapeOptions {
borderRadiusSm?: number;
borderRadiusMd?: number;
borderRadiusLg?: number;
borderRadiusXl?: number;
}
}