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

v9로 업그레이드하기

원문 보기 위키 갱신

v9로 업그레이드하기 (Upgrade to v9)

이 문서는 Material UI v6에서 v9로 마이그레이션할 때 필요한 깨지는 변경 사항을 정리한 참고 가이드예요. 대부분 deprecated된 prop·클래스가 제거된 것이 핵심이라, 각 항목마다 codemod와 교체 코드 예시를 함께 소개할게요.

출처: 문서

본문

v9로 올라가면서 여러 deprecated API가 제거되었어요. 가장 큰 변화는 components/componentsProps 같은 구식 prop이 완전히 없어지고 slots/slotProps로 통일된다는 점, 그리고 복합 CSS 클래스가 atomic 클래스로 분해된다는 점이에요. 각 컴포넌트별로 자동 마이그레이션을 도와주는 codemod가 제공되니, 가능하면 그것부터 실행해보는 걸 추천해요.

System props

Box, DialogContentText, Grid, Link, Stack, Typography, TimelineContent, TimelineOppositeContent 컴포넌트에서 system props가 제거됐어요. 모두 sx prop으로 옮겨가야 해요.

npx @mui/codemod@latest v9.0.0/system-props <path/to/folder>

자동 import 플러그인(예: unplugin-auto-import)을 써서 명시적 import 없이 컴포넌트를 쓰는 프로젝트라면 --jsx 옵션으로 대상 JSX 태그를 지정할 수 있어요.

npx @mui/codemod@latest v9.0.0/system-props <path/to/folder> -- --jsx=Box,Typography,Stack,Link,Grid,DialogContentText
-<Box mt={2} color="primary.main" />
+<Box sx={{ mt: 2, color: 'primary.main' }} />

-<Grid mt={2} mr={1} />
+<Grid sx={{ mt: 2, mr: 1 }} />

-<Link mt={2} color="text.secondary" />
+<Link sx={{ mt: 2, color: 'text.secondary' }} />

-<Stack mt={2} alignItems="center" />
+<Stack sx={{ mt: 2, alignItems: 'center' }} />

-<Typography mt={2} fontWeight="bold" />
+<Typography sx={{ mt: 2, fontWeight: 'bold' }} />

또한 이 변경은 color 같은 prop이 component prop으로 렌더링되는 요소에 전달되지 않고 컴포넌트가 소비해버리던 문제도 함께 해결해줘요.

// `color`는 이제 Button으로 올바르게 전달된다
<Grid component={Button} color="secondary" variant="contained">
  hello
</Grid>

공통 패턴: slots/slotProps 통일

많은 컴포넌트에서 components → slots, componentsProps → slotProps, 그리고 <SlotName>Component/<SlotName>Props 형태의 prop들이 제거되었어요. 예시를 함께 볼게요.

Checkbox — inputProps → slotProps.input, inputRef → slotProps.input.ref:

 <Checkbox
-  inputProps={{ 'aria-label': 'Checkbox' }}
-  inputRef={ref}
+  slotProps={{ input: { 'aria-label': 'Checkbox', ref } }}
 />

CardHeader — titleTypographyProps → slotProps.title, subheaderTypographyProps → slotProps.subheader:

 <CardHeader
-  titleTypographyProps={{ className: 'my-title' }}
-  subheaderTypographyProps={{ className: 'my-subheader' }}
+  slotProps={{ title: { className: 'my-title' }, subheader: { className: 'my-subheader' } }}
 />

Dialog — BackdropComponent/BackdropProps/PaperProps/TransitionComponent/TransitionProps 제거:

 <Dialog
-  BackdropComponent={CustomBackdrop}
-  BackdropProps={{ invisible: true }}
-  PaperProps={{ elevation: 3 }}
-  TransitionComponent={CustomTransition}
-  TransitionProps={{ timeout: 500 }}
+  slots={{ backdrop: CustomBackdrop, transition: CustomTransition }}
+  slotProps={{ backdrop: { invisible: true }, paper: { elevation: 3 }, transition: { timeout: 500 } }}
 />

Menu — MenuListProps → slotProps.list, PaperProps → slotProps.paper, TransitionProps → slotProps.transition:

 <Menu
-  MenuListProps={{ disablePadding: true }}
-  PaperProps={{ elevation: 12 }}
-  TransitionProps={{ timeout: 500 }}
+  slotProps={{
+    list: { disablePadding: true },
+    paper: { elevation: 12 },
+    transition: { timeout: 500 },
+  }}
 />

Select의 MenuProps 안에서 같은 prop을 쓰고 있었다면 이렇게 바꿔요.

 <Select
   MenuProps={{
-    PaperProps: { style: { maxHeight: 200 } },
-    MenuListProps: { disablePadding: true },
-    TransitionProps: { timeout: 500 },
+    slotProps: {
+      paper: { style: { maxHeight: 200 } },
+      list: { disablePadding: true },
+      transition: { timeout: 500 },
+    },
   }}
 />

Modal — BackdropComponent/BackdropProps/components/componentsProps 제거:

 <Modal
-  BackdropComponent={CustomBackdrop}
-  BackdropProps={{ invisible: true }}
-  components={{ Root: CustomRoot }}
-  componentsProps={{ root: { className: 'custom' } }}
+  slots={{ backdrop: CustomBackdrop, root: CustomRoot }}
+  slotProps={{ backdrop: { invisible: true }, root: { className: 'custom' } }}
 />

TextField — InputProps/inputProps/SelectProps/InputLabelProps/FormHelperTextProps 제거:

 <TextField
-  InputProps={CustomInputProps}
-  inputProps={CustomHtmlInputProps}
-  SelectProps={CustomSelectProps}
-  InputLabelProps={CustomInputLabelProps}
-  FormHelperTextProps={CustomFormHelperTextProps}
+  slotProps={{
+    input: CustomInputProps,
+    htmlInput: CustomHtmlInputProps,
+    select: CustomSelectProps,
+    inputLabel: CustomInputLabelProps,
+    formHelperText: CustomFormHelperTextProps,
+  }}
 />

Autocomplete에서 TextField를 렌더링한다면 params의 형태도 새 TextField API에 맞춰 바뀌어요.

 <Autocomplete
   renderInput={(params) => (
     <TextField
       {...params}
-      inputProps={{
-        ...params.inputProps,
-        autoComplete: 'new-password',
+      slotProps={{
+        ...params.slotProps,
+        htmlInput: {
+          ...params.slotProps.htmlInput,
+          autoComplete: 'new-password',
+        },
       }}
     />
   )}

Tooltip — components/componentsProps/PopperComponent/PopperProps/TransitionComponent/TransitionProps 제거:

 <Tooltip
   title="Hello World"
-  components={{ Popper: CustomPopper, Tooltip: CustomTooltip, Transition: CustomTransition, Arrow: CustomArrow }}
-  componentsProps={{ popper: { placement: 'top' }, tooltip: { className: 'custom' }, arrow: { className: 'arrow' } }}
-  PopperComponent={CustomPopper}
-  PopperProps={{ disablePortal: true }}
-  TransitionComponent={CustomTransition}
-  TransitionProps={{ timeout: 500 }}
+  slots={{ popper: CustomPopper, tooltip: CustomTooltip, transition: CustomTransition, arrow: CustomArrow }}
+  slotProps={{
+    popper: { placement: 'top', disablePortal: true },
+    tooltip: { className: 'custom' },
+    transition: { timeout: 500 },
+    arrow: { className: 'arrow' },
+  }}
 />

Drawer — BackdropComponent/BackdropProps/PaperProps/SlideProps/TransitionComponent 제거:

 <Drawer
-  BackdropComponent={CustomBackdrop}
-  BackdropProps={{ invisible: true }}
-  PaperProps={{ elevation: 2 }}
-  SlideProps={{ timeout: 500 }}
-  TransitionComponent={CustomTransition}
+  slots={{ backdrop: CustomBackdrop, transition: CustomTransition }}
+  slotProps={{ backdrop: { invisible: true }, paper: { elevation: 2 }, transition: { timeout: 500 } }}
 />

복합 CSS 클래스 → atomic 클래스

variant·color·size 등을 조합한 클래스가 제거되고 기본 클래스 조합으로 바뀌었어요. 대표적으로 보면:

-.MuiButton-textPrimary
+.MuiButton-text.MuiButton-colorPrimary
-.MuiButton-containedSizeSmall
+.MuiButton-contained.MuiButton-sizeSmall
-.MuiButton-root .MuiButton-iconSizeMedium
+.MuiButton-root.MuiButton-sizeMedium > .MuiButton-icon
-.MuiAlert-standardSuccess
+.MuiAlert-standard.MuiAlert-colorSuccess
-.MuiChip-clickableColorPrimary
+.MuiChip-clickable.MuiChip-colorPrimary
-.MuiSlider-thumbColorPrimary
+.MuiSlider-colorPrimary > .MuiSlider-thumb

테마의 styleOverrides에서 이런 클래스를 키로 쓰고 있었다면, root(또는 해당 슬롯)의 variants 배열로 옮겨가요.

Button 예시:

 const theme = createTheme({
   components: {
     MuiButton: {
       styleOverrides: {
-        textPrimary: { color: 'blue' },
-        containedSizeSmall: { fontSize: '0.75rem' },
-        iconSizeMedium: { fontSize: '20px' },
+        root: {
+          variants: [
+            { props: { variant: 'text', color: 'primary' }, style: { color: 'blue' } },
+            { props: { variant: 'contained', size: 'small' }, style: { fontSize: '0.75rem' } },
+            { props: { size: 'medium' }, style: { '& .MuiButton-icon': { fontSize: '20px' } } },
+          ],
+        },
       },
     },
   },
 });

ButtonGroup 예시:

 const theme = createTheme({
   components: {
     MuiButtonGroup: {
       styleOverrides: {
-        groupedContainedPrimary: { borderColor: 'red' },
+        root: {
+          variants: [
+            {
+              props: { variant: 'contained', color: 'primary' },
+              style: {
+                '& > .MuiButtonGroup-grouped': { borderColor: 'red' },
+              },
+            },
+          ],
+        },
       },
     },
   },
 });

Chip 예시 (자식 요소를 노리는 클래스는 root variants 안의 CSS 자식 선택자로):

 const theme = createTheme({
   components: {
     MuiChip: {
       styleOverrides: {
-        clickableColorPrimary: { boxShadow: 'none' },
-        avatarColorPrimary: { color: 'white' },
-        labelSmall: { padding: '0 6px' },
+        root: {
+          variants: [
+            { props: { clickable: true, color: 'primary' }, style: { boxShadow: 'none' } },
+            { props: { color: 'primary' }, style: { '& .MuiChip-avatar': { color: 'white' } } },
+          ],
+        },
+        label: {
+          variants: [
+            { props: { size: 'small' }, style: { padding: '0 6px' } },
+          ],
+        },
       },
     },
   },
 });

CircularProgress — circleDeterminate/circleIndeterminate → circle의 variants:

 const theme = createTheme({
   components: {
     MuiCircularProgress: {
       styleOverrides: {
-        circleDeterminate: { strokeDashoffset: '10px' },
-        circleIndeterminate: { animationDuration: '1.4s' },
+        circle: {
+          variants: [
+            { props: { variant: 'determinate' }, style: { strokeDashoffset: '10px' } },
+            { props: { variant: 'indeterminate' }, style: { animationDuration: '1.4s' } },
+          ],
+        },
       },
     },
   },
 });

LinearProgress — bar1Determinate/barColorPrimary/dashedColorPrimary 등:

 const theme = createTheme({
   components: {
     MuiLinearProgress: {
       styleOverrides: {
-        bar1Determinate: { transition: 'none' },
-        barColorPrimary: { backgroundColor: 'red' },
-        dashedColorPrimary: { backgroundSize: '10px 10px' },
+        bar1: {
+          variants: [
+            { props: { variant: 'determinate' }, style: { transition: 'none' } },
+          ],
+        },
+        bar: {
+          variants: [
+            { props: { color: 'primary' }, style: { backgroundColor: 'red' } },
+          ],
+        },
+        dashed: {
+          variants: [
+            { props: { color: 'primary' }, style: { backgroundSize: '10px 10px' } },
+          ],
+        },
       },
     },
   },
 });

InputBase — 조합 클래스 대신 root 슬롯에 결합 클래스 선택자 사용:

 import { inputBaseClasses } from '@mui/material/InputBase';

 const theme = createTheme({
   components: {
     MuiInputBase: {
       styleOverrides: {
-        inputSizeSmall: { padding: 1 },
-        inputMultiline: { resize: 'none' },
+        root: {
+          [`&.${inputBaseClasses.sizeSmall} > .${inputBaseClasses.input}`]: { padding: 1 },
+          [`&.${inputBaseClasses.multiline} > .${inputBaseClasses.input}`]: { resize: 'none' },
+        },
       },
     },
   },
 });

Select — iconFilled/iconOutlined/iconStandard → 형제 선택자:

 import { selectClasses } from '@mui/material/Select';

 const theme = createTheme({
   components: {
     MuiSelect: {
       styleOverrides: {
         root: {
-          [`& .${selectClasses.iconFilled}`]: {
+          [`& .${selectClasses.filled} ~ .${selectClasses.icon}`]: {
             color: 'red',
           },
         },
       },
     },
   },
 });

StepConnector — lineHorizontal/lineVertical → line의 variants:

 const theme = createTheme({
   components: {
     MuiStepConnector: {
       styleOverrides: {
-        lineHorizontal: { borderTopWidth: 3 },
-        lineVertical: { borderLeftWidth: 3 },
+        line: {
+          variants: [
+            { props: { orientation: 'horizontal' }, style: { borderTopWidth: 3 } },
+            { props: { orientation: 'vertical' }, style: { borderLeftWidth: 3 } },
+          ],
+        },
       },
     },
   },
 });

기타 컴포넌트별 단순 prop 교체

Divider — light prop 제거, sx={{ opacity: 0.6 }} 사용:

 <Divider
-  light
+  sx={{ opacity: 0.6 }}
 />

FormControlLabel — componentsProps → slotProps:

 <FormControlLabel
-  componentsProps={{ typography: { fontWeight: 'bold' } }}
+  slotProps={{ typography: { fontWeight: 'bold' } }}
 />

ListItem — components/componentsProps/ContainerComponent/ContainerProps 제거. 또한 styleOverrides의 secondaryAction 키가 이제 root가 아닌 secondaryAction 슬롯을 가리켜요.

 <ListItem
-  components={{ Root: CustomRoot }}
-  componentsProps={{ root: { className: 'custom' } }}
+  slots={{ root: CustomRoot }}
+  slotProps={{ root: { className: 'custom' } }}
 />
 const theme = createTheme({
   components: {
     MuiListItem: {
       styleOverrides: {
-        secondaryAction: {
-          [`& .${listItemClasses.secondaryAction}`]: {
-            // styles
-          },
-        },
+        secondaryAction: {
+          // styles applied directly to the secondaryAction slot
+        },
       },
     },
   },
 });

ListItemText — primaryTypographyProps → slotProps.primary, secondaryTypographyProps → slotProps.secondary:

 <ListItemText
-  primaryTypographyProps={{ variant: 'h6' }}
-  secondaryTypographyProps={{ color: 'textSecondary' }}
+  slotProps={{
+    primary: { variant: 'h6' },
+    secondary: { color: 'textSecondary' },
+  }}
 />

MobileStepper — LinearProgressProps → slotProps.progress:

 <MobileStepper
-  LinearProgressProps={{ className: 'progress' }}
+  slotProps={{ progress: { className: 'progress' } }}
 />

PaginationItem — components → slots, 조합 클래스 제거:

 <PaginationItem
-  components={{
-    first: MyFirstIcon,
-    last: MyLastIcon,
-    previous: MyPreviousIcon,
-    next: MyNextIcon,
-  }}
+  slots={{
+    first: MyFirstIcon,
+    last: MyLastIcon,
+    previous: MyPreviousIcon,
+    next: MyNextIcon,
+  }}
 />
-.MuiPaginationItem-textPrimary
+.MuiPaginationItem-text.MuiPaginationItem-colorPrimary

Radio — inputProps → slotProps.input, inputRef → slotProps.input.ref:

 <Radio
-  inputProps={{ 'aria-label': 'Radio' }}
-  inputRef={ref}
+  slotProps={{ input: { 'aria-label': 'Radio', ref } }}
 />

Rating — IconContainerComponent → slotProps.icon.component:

 <Rating
-  IconContainerComponent={CustomIconContainer}
+  slotProps={{ icon: { component: CustomIconContainer } }}
 />

Snackbar — ClickAwayListenerProps/ContentProps/TransitionComponent/TransitionProps 제거:

 <Snackbar
-  ClickAwayListenerProps={CustomClickAwayListenerProps}
-  ContentProps={CustomContentProps}
-  TransitionComponent={CustomTransition}
-  TransitionProps={CustomTransitionProps}
+  slots={{ transition: CustomTransition }}
+  slotProps={{
+    clickAwayListener: CustomClickAwayListenerProps,
+    content: CustomContentProps,
+    transition: CustomTransitionProps,
+  }}
 />

SpeedDial / SpeedDialAction — transition 관련 prop과 FabProps/tooltip* prop들이 slots/slotProps로 이동:

 <SpeedDial
-  TransitionComponent={CustomTransition}
-  TransitionProps={{ timeout: 500 }}
+  slots={{ transition: CustomTransition }}
+  slotProps={{ transition: { timeout: 500 } }}
 >
 <SpeedDialAction
-  FabProps={{ size: 'large' }}
-  tooltipTitle="Add"
-  tooltipPlacement="right"
-  tooltipOpen
-  TooltipClasses={{ tooltip: 'custom' }}
+  slotProps={{
+    fab: { size: 'large' },
+    tooltip: {
+      title: 'Add',
+      placement: 'right',
+      open: true,
+      classes: { tooltip: 'custom' },
+    },
+  }}

StepContent — TransitionComponent → slots.transition, TransitionProps → slotProps.transition:

 <StepContent
-  TransitionComponent={CustomTransition}
-  TransitionProps={{ unmountOnExit: true }}
+  slots={{ transition: CustomTransition }}
+  slotProps={{ transition: { unmountOnExit: true } }}
 />

StepLabel — componentsProps/StepIconComponent/StepIconProps 제거:

 <StepLabel
-  StepIconComponent={CustomIcon}
-  StepIconProps={{ error: true }}
-  componentsProps={{ label: { className: 'my-label' } }}
+  slots={{ stepIcon: CustomIcon }}
+  slotProps={{ stepIcon: { error: true }, label: { className: 'my-label' } }}
 />

Switch — inputProps/inputRef 제거:

 <Switch
-  inputProps={{ 'aria-label': 'Switch' }}
-  inputRef={ref}
+  slotProps={{ input: { 'aria-label': 'Switch', ref } }}
 />

SwipeableDrawer — BackdropComponent/BackdropProps/SwipeAreaProps 제거:

 <SwipeableDrawer
-  BackdropComponent={CustomBackdrop}
-  BackdropProps={{ invisible: true }}
-  SwipeAreaProps={{ className: 'custom' }}
+  slots={{ backdrop: CustomBackdrop }}
+  slotProps={{ backdrop: { invisible: true }, swipeArea: { className: 'custom' } }}
 />

TablePagination — backIconButtonProps → slotProps.actions.previousButton, nextIconButtonProps → slotProps.actions.nextButton:

 <TablePagination
-  backIconButtonProps={CustomBackIconButtonProps}
-  nextIconButtonProps={CustomNextIconButtonProps}
+  slotProps={{
+    actions: {
+      previousButton: CustomBackIconButtonProps,
+      nextButton: CustomNextIconButtonProps,
+    },
+  }}
 />

Tab — iconWrapper 클래스 제거:

-.MuiTab-iconWrapper
+.MuiTab-icon

Tabs — flexContainer → list, ToggleButtonGroup의 groupedHorizontal/groupedVertical 제거:

-.MuiTabs-flexContainer
+.MuiTabs-list
-.MuiTabs-flexContainerVertical
+.MuiTabs-list.MuiTabs-vertical
-.MuiToggleButtonGroup-groupedHorizontal
+.MuiToggleButtonGroup-horizontal > .MuiToggleButtonGroup-grouped

Theme styleOverrides → variants 요약

styleOverrides에 조합 클래스를 키로 쓰던 코드는 전부 variants 배열(또는 결합 클래스 선택자)로 옮기면 돼요. variants는 root뿐 아니라 label, circle, bar, line 같은 다른 슬롯에서도 정의할 수 있고, props 매칭으로 세밀한 조건을 거는 게 핵심이에요. 이 변경 덕분에 조합 클래스가 사라지고 API가 훨씬 단순해져요.

더 알아보기 (Learn more)