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

더 이상 쓰이지 않는 API에서 마이그레이션하기

원문 보기 위키 갱신

더 이상 쓰이지 않는 API에서 마이그레이션하기 (Migrating from deprecated APIs)

최근에 deprecated된 API들이 완전히 깨지는 변경이 되기 전에, 이 문서를 따라 안전하게 새 API로 옮겨가는 방법을 배워봐요. 각 컴포넌트별로 어떤 prop·클래스가 deprecated되었고, 어떤 식으로 교체해야 하는지 실제 코드 예시와 함께 정리했어요.

출처: 문서

본문

왜 마이그레이션해야 할까요

기능은 유지보수 담당자가 API를 개선하면서 시간이 지남에 따라 deprecated됩니다. 개선된 API로 옮겨가면 개발자 경험이 좋아지고, deprecated된 API는 보통 다음 메이저 버전에서 깨지는 변경이 되기 때문에 최대한 빨리 옮기는 것이 다음 업데이트를 부드럽게 만들어줘요.

마이그레이션 방법

Material UI는 deprecations/all codemod를 제공해서 최소한의 노력으로 최신 상태를 유지할 수 있게 도와줘요.

npx @mui/codemod@latest deprecations/all <path>

이 명령은 현재의 deprecations codemods를 모두 실행해서 업데이트된 API로 자동으로 마이그레이션해줘요. 필요할 때마다 반복해서 실행하면 되요.

:::info 수동으로 deprecated API에서 옮겨가야 한다면, 아래에 Material UI v5에서 추가된 모든 deprecation에 대한 예시가 있어요. 특정 codemod만 실행하고 싶다면 그것도 아래에 링크로 나와 있으니 참고해요. :::

패키지 전반의 deprecated API

내부 요소 오버라이드 (Inner element overrides)

slots와 slotProps API가 표준화되고 있는 중이에요. 이에 대응되는 components, componentsProps, <SlotName>Component, <SlotName>Props 같은 API는 deprecated되어 결국 제거될 예정이에요. 일관성과 예측 가능성, 인지 부하 감소 측면에서 개발자 경험이 좋아져요.

복합 CSS 클래스 (Composed CSS classes)

복합 CSS 클래스는 atomic 클래스 대안을 위해 deprecated되고 결국 제거될 예정이에요. 예를 들어 .MuiAccordionSummary-contentGutters 클래스는 .MuiAccordionSummary-gutters와 .MuiAccordionSummary-content 클래스로 대체되었어요.

시스템 props (System props)

mt={*}, bgcolor={*} 같은 MUI System props가 Box, Typography, Link, Grid, Stack 컴포넌트에서 deprecated되었어요. 아래 codemod로 모든 System props를 sx prop으로 옮겨가요.

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

수동으로도 아래처럼 수정할 수 있어요.

-<Button mr={2}>
+<Button sx={{ mr: 2 }}>

sx prop은 시스템 props의 모든 기능(테마 접근 콜백, 반응형 값, 테마 값 직접 접근, 단축 표기 등)을 지원해요.

테마 컴포넌트 variants (Theme component variants)

테마에서 정의한 커스텀 컴포넌트 variants는 이제 컴포넌트의 root 슬롯 안에 정의된 테마 style overrides와 병합돼요.

npx @mui/codemod@latest v6.0.0/theme-v6 <path/to/theme>
 createTheme({
   components: {
     MuiButton: {
-      variants: [ ... ],
+      styleOverrides: {
+        root: {
+          variants: [ ... ],
+        },
+      },
     },
   },
 });

이렇게 하면 API 표면이 줄어들고 컴포넌트의 다른 슬롯에서도 variants를 정의할 수 있게 돼요.

Accordion

아래 codemod를 사용해요.

npx @mui/codemod@latest deprecations/accordion-props <path>

TransitionComponent prop은 slots.transition으로, TransitionProps prop은 slotProps.transition으로 대체됐어요.

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

AccordionSummary

npx @mui/codemod@latest deprecations/accordion-summary-classes <path>

.MuiAccordionSummary-contentGutters 클래스는 .MuiAccordionSummary-gutters와 .MuiAccordionSummary-content로 대체됐어요. 주의할 점은 .MuiAccordionSummary-gutters는 컴포넌트 root에 적용되고, 다른 두 클래스는 content 요소에 적용돼요.

-.MuiAccordionSummary-root .MuiAccordionSummary-contentGutters
+.MuiAccordionSummary-root.MuiAccordionSummary-gutters .MuiAccordionSummary-content
 import { accordionSummaryClasses } from '@mui/material/AccordionSummary';

 MuiAccordionSummary: {
   styleOverrides: {
     root: {
-      [`& .${accordionSummaryClasses.contentGutters}`]: {
+      [`&.${accordionSummaryClasses.gutters} .${accordionSummaryClasses.content}`]: {
         color: 'red',
       },
     },
   },
 }

Alert

npx @mui/codemod@latest deprecations/alert-props <path>
npx @mui/codemod@latest deprecations/alert-classes <path>

components → slots, componentsProps → slotProps로 대체됐어요.

 <Alert
-  components={{ CloseButton: CustomButton }}
+  slots={{ closeButton: CustomButton }}
 />
 <Alert
-  componentsProps={{ closeButton: { id: 'close-id' } }}
+  slotProps={{ closeButton: { id: 'close-id' } }}
 />

severity(또는 variant)와 color prop을 조합하던 복합 CSS 클래스(예: .MuiAlert-standardSuccess)도 제거됐어요.

-.MuiAlert-standardSuccess
+.MuiAlert-standard.MuiAlert-colorSuccess
-.MuiAlert-outlinedError
+.MuiAlert-outlined.MuiAlert-colorError
-.MuiAlert-filledWarning
+.MuiAlert-filled.MuiAlert-colorWarning
 import { alertClasses } from '@mui/material/Alert';

 MuiAlert: {
   styleOverrides: {
     root: {
-      [`&.${alertClasses.standardSuccess}`]: {
+      [`&.${alertClasses.standard}.${alertClasses.colorSuccess}`]: {
         color: 'red',
       },
-      [`&.${alertClasses.filledError}`]: {
+      [`&.${alertClasses.filled}.${alertClasses.colorError}`]: {
         color: 'red',
       },
     },
   },
 }

Autocomplete

npx @mui/codemod@latest deprecations/autocomplete-props <path>

모든 슬롯(*Component) prop은 slots·slotProps로, 슬롯 props(*Props)는 slotProps로 대체됐어요.

 <Autocomplete
-  PaperComponent={CustomPaperComponent}
-  PopperComponent={CustomPopperComponent}
-  ListboxComponent={CustomListboxComponent}
+  slots={{
+    paper: CustomPaperComponent,
+    popper: CustomPopperComponent,
+  }}
+  slotProps={{
+    listbox: {
+      component: CustomListboxComponent,
+    },
+  }}
 />

:::warning listbox 슬롯은 특별한 경우예요. ListboxComponent가 다른 *Component prop들과 다르게 구현되어 component·as prop과 비슷하게 동작하기 때문이에요. slots.listbox 항목이 존재하므로 컴포넌트를 완전히 교체할 수 있지만, 기존 listbox 스타일을 유지하는 ListboxComponent의 동작을 유지하고 싶다면 slotProps.listbox.component 항목을 사용해야 해요. :::

 <Autocomplete
-  ChipProps={CustomChipProps}
-  ListboxProps={CustomListboxProps}
+  slotProps={{
+    chip: CustomChipProps,
+    listbox: CustomListboxProps,
+  }}
 />
 <Autocomplete
-  componentsProps={{
-    clearIndicator: { width: 10 },
-    paper: { width: 12 },
-    popper: { width: 14 },
-    popupIndicator: { width: 16 },
+  slotProps={{
+    clearIndicator: { width: 10 },
+    paper: { width: 12 },
+    popper: { width: 14 },
+    popupIndicator: { width: 16 },
   }}
 />

Avatar

npx @mui/codemod@latest deprecations/avatar-props <path>

imgProps → slotProps.img로 대체됐어요.

 <Avatar
-  imgProps={{
-    onError: () => {},
-    onLoad: () => {},
+  slotProps={{
+    img: {
+      onError: () => {},
+      onLoad: () => {},
+    }
   }}
 />;

AvatarGroup

npx @mui/codemod@latest deprecations/avatar-group-props <path>

slotProps.additionalAvatar → slotProps.surplus, componentsProps → slotProps로 대체됐어요.

 <AvatarGroup
   slotProps={{
-    additionalAvatar: { color: 'red' },
+    surplus: { color: 'red' },
   }}
 >
 <AvatarGroup
-  componentsProps={{
-    additionalAvatar: { color: 'red' },
+  slotProps={{
+    surplus: { color: 'red' },
   }}
 >

Backdrop

npx @mui/codemod@latest deprecations/backdrop-props <path>

components → slots, componentsProps → slotProps, TransitionComponent → slots.transition로 대체됐어요.

 <Backdrop
-  components={{ root: CustomRoot }}
+  slots={{ root: CustomRoot }}
 />
 <Backdrop
-  componentsProps={{ root: { id: 'root-id' } }}
+  slotProps={{ root: { id: 'root-id' } }}
 />
 <Backdrop
-  TransitionComponent={CustomTransition}
+  slots={{ transition: CustomTransition }}

Badge

npx @mui/codemod@latest deprecations/badge-props <path>

components → slots, componentsProps → slotProps로 대체됐어요.

 <Badge
-  components={{ root: CustomRoot }}
+  slots={{ root: CustomRoot }}
 >
 <Badge
-  componentsProps={{ root: { id: 'root-id' } }}
+  slotProps={{ root: { id: 'root-id' } }}
 >

Button

npx @mui/codemod@latest deprecations/button-classes <path>

variant·color, variant·size를 조합한 복합 CSS 클래스와 icon size 클래스가 제거됐어요.

-.MuiButton-textPrimary
+.MuiButton-text.MuiButton-colorPrimary
-.MuiButton-outlinedSecondary
+.MuiButton-outlined.MuiButton-colorSecondary
-.MuiButton-containedSuccess
+.MuiButton-contained.MuiButton-colorSuccess
-.MuiButton-textSizeSmall
+.MuiButton-text.MuiButton-sizeSmall
-.MuiButton-outlinedSizeLarge
+.MuiButton-outlined.MuiButton-sizeLarge
-.MuiButton-root .MuiButton-iconSizeMedium
+.MuiButton-root.MuiButton-sizeMedium > .MuiButton-icon
 import { buttonClasses } from '@mui/material/Button';

 MuiButton: {
   styleOverrides: {
     root: {
-      [`&.${buttonClasses.textInherit}`]: {
+      [`&.${buttonClasses.text}.${buttonClasses.colorInherit}`]: {
         color: 'red',
       },
-      [`&.${buttonClasses.containedSizeSmall}`]: {
+      [`&.${buttonClasses.contained}.${buttonClasses.sizeSmall}`]: {
         color: 'red',
       },
-      [`& .${buttonClasses.iconSizeLarge}`]: {
+      [`&.${buttonClasses.sizeLarge} > .${buttonClasses.icon}`]: {
         color: 'red',
       },
     },
   },
 }

ButtonGroup

npx @mui/codemod@latest deprecations/button-group-classes <path>

orientation·variant·grouped와 color·variant·grouped를 조합한 클래스가 deprecated됐어요.

-.MuiButtonGroup-root .MuiButtonGroup-groupedHorizontal
+.MuiButtonGroup-root.MuiButtonGroup-horizontal > .MuiButtonGroup-grouped
-.MuiButtonGroup-root .MuiButtonGroup-groupedTextPrimary
+.MuiButtonGroup-root.MuiButtonGroup-text.MuiButtonGroup-colorPrimary > .MuiButtonGroup-grouped
-.MuiButtonGroup-root .MuiButtonGroup-groupedContainedVertical
+.MuiButtonGroup-root.MuiButtonGroup-contained.MuiButtonGroup-vertical > .MuiButtonGroup-grouped
 import { buttonGroupClasses } from '@mui/material/ButtonGroup';

 MuiButtonGroup: {
   styleOverrides: {
     root: {
-      [`& .${buttonGroupClasses.groupedHorizontal}`]: {
+      [`&.${buttonGroupClasses.horizontal} > .${buttonGroupClasses.grouped}`]: {
         color: 'red',
       },
-      [`& .${buttonGroupClasses.groupedContainedSecondary}`]: {
+      [`&.${buttonGroupClasses.contained}.${buttonGroupClasses.colorSecondary} > .${buttonGroupClasses.grouped}`]: {
         color: 'red',
       },
     },
   },
 }

CardHeader

npx @mui/codemod@latest deprecations/card-header-props <path>

titleTypographyProps → slotProps.title, subheaderTypographyProps → slotProps.subheader로 대체됐어요.

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

Chip

npx @mui/codemod@latest deprecations/chip-classes <path>

variant·clickable·deletable·color, avatar, icon, deleteIcon, label과 관련된 복합 CSS 클래스가 deprecated됐어요.

-.MuiChip-clickableColorPrimary
+.MuiChip-clickable.MuiChip-colorPrimary
-.MuiChip-outlinedSecondary
+.MuiChip-outlined.MuiChip-colorSecondary
-.MuiChip-root .MuiChip-avatarSmall
+.MuiChip-root.MuiChip-sizeSmall > .MuiChip-avatar
-.MuiChip-root .MuiChip-deleteIconFilledColorPrimary
+.MuiChip-root.MuiChip-filled.MuiChip-colorPrimary > .MuiChip-deleteIcon
 import { chipClasses } from '@mui/material/Chip';

 MuiChip: {
   styleOverrides: {
     root: {
-      [`&.${chipClasses.clickableColorPrimary}`]: {
+      [`&.${chipClasses.clickable}.${chipClasses.colorPrimary}`]: {
         color: 'red',
       },
-      [`& .${chipClasses.avatarColorSecondary}`]: {
+      [`&.${chipClasses.colorSecondary} > .${chipClasses.avatar}`]: {
         color: 'red',
       },
-      [`& .${chipClasses.labelMedium}`]: {
+      [`&.${chipClasses.sizeMedium} > .${chipClasses.label}`]: {
         color: 'red',
       },
     },
   },
 }

CircularProgress

npx @mui/codemod@latest deprecations/circular-progress-classes <path>

circle CSS 클래스와 variant prop을 조합한 클래스가 제거됐어요.

-.MuiCircularProgress-circleDeterminate
-.MuiCircularProgress-circleIndeterminate
+.MuiCircularProgress-determinate > .MuiCircularProgress-circle
+.MuiCircularProgress-indeterminate > .MuiCircularProgress-circle
 import { circularProgressClasses } from '@mui/material/CircularProgress';

 MuiCircularProgress: {
   styleOverrides: {
     root: {
-      [`& .${circularProgressClasses.circleDeterminate}`]: {
+      [`&.${circularProgressClasses.determinate} > .${circularProgressClasses.circle}`]: {
         color: 'red',
       },
     },
   },
 }

Divider

npx @mui/codemod@latest deprecations/divider-props <path>

light prop이 deprecated됐어요. sx={{ opacity: "0.6" }} (또는 어떤 opacity 값이든) 을 사용해요.

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

Dialog

npx @mui/codemod@latest deprecations/dialog-classes <path>
npx @mui/codemod@latest deprecations/dialog-props <path>

scroll prop을 조합한 클래스가 제거되고, TransitionComponent → slots.transition, TransitionProps → slotProps.transition, PaperProps → slotProps.paper로 대체됐어요.

-.MuiDialog-root .MuiDialog-paperScrollBody
+.MuiDialog-root .MuiDialog-scrollBody > .MuiDialog-paper
-.MuiDialog-root .MuiDialog-paperScrollPaper
+.MuiDialog-root .MuiDialog-scrollPaper > .MuiDialog-paper
 import { dialogClasses } from '@mui/material/Dialog';

 MuiDialog: {
   styleOverrides: {
     root: {
-      [`& .${dialogClasses.paperScrollBody}`]: {
+      [`& .${dialogClasses.scrollBody} > .${dialogClasses.paper}`]: {
         color: 'red',
       },
     },
   },
 }
 <Dialog
-  TransitionComponent={CustomTransition}
-  TransitionProps={{ unmountOnExit: true }}
-  PaperProps={paperProps}
+  slots={{ transition: CustomTransition }}
+  slotProps={{ transition: { unmountOnExit: true }, paper: paperProps }}
 />

Drawer

npx @mui/codemod@latest deprecations/drawer-props <path>
npx @mui/codemod@latest deprecations/drawer-classes <path>

BackdropProps → slotProps.backdrop, PaperProps → slotProps.paper, SlideProps → slotProps.transition로 대체되고, paper·anchor·docked를 조합한 클래스도 deprecated됐어요.

 <Drawer
-  BackdropProps={backdropProps}
-  PaperProps={paperProps}
-  SlideProps={slideProps}
+  slotProps={{ backdrop: backdropProps, paper: paperProps, transition: slideProps }}
 />
-.MuiDrawer-paperAnchorLeft
+.MuiDrawer-anchorLeft > .MuiDrawer-paper
-.MuiDrawer-paperAnchorDockedBottom
+.MuiDrawer-docked.MuiDrawer-anchorBottom > .MuiDrawer-paper
 import { drawerClasses } from '@mui/material/Drawer';

 MuiDrawer: {
   styleOverrides: {
     root: {
-      [`.${drawerClasses.paperAnchorRight}`]: {
+      [`&.${drawerClasses.anchorRight} > .${drawerClasses.paper}`]: {
         color: 'red',
       },
     },
   },
 }

FilledInput / Input / OutlinedInput

npx @mui/codemod@latest deprecations/filled-input-props <path>
npx @mui/codemod@latest deprecations/input-props <path>
npx @mui/codemod@latest deprecations/outlined-input-props <path>

components → slots, componentsProps → slotProps로 대체됐어요.

 <FilledInput
-  components={{ Input: CustomInput, Root: CustomRoot }}
-  componentsProps={{ input: { id: 'test-input-id', root: { id: 'test-root-id' } } }}
+  slots={{ input: CustomInput, root: CustomRoot }}
+  slotProps={{ input: { id: 'test-input-id', root: { id: 'test-root-id' } } }}
 />

FormControlLabel

npx @mui/codemod@latest deprecations/form-control-label-props <path>

componentsProps → slotProps로 대체됐어요.

 <FormControlLabel
-  componentsProps={{ typography: typographyProps }}
+  slotProps={{ typography: typographyProps }}
 />

InputBase

npx @mui/codemod@latest deprecations/input-base-props <path>
npx @mui/codemod@latest deprecations/input-base-classes <path>

input 클래스와 size·type·multiline·adornedStart·adornedEnd·hiddenLabel prop을 조합한 클래스가 제거됐어요.

-.MuiInputBase-root .MuiInputBase-inputSizeSmall
+.MuiInputBase-root.MuiInputBase-sizeSmall > .MuiInputBase-input
-.MuiInputBase-root .MuiInputBase-inputMultiline
+.MuiInputBase-root.MuiInputBase-multiline > .MuiInputBase-input
-.MuiInputBase-root .MuiInputBase-inputAdornedEnd
+.MuiInputBase-root.MuiInputBase-adornedEnd > .MuiInputBase-input
 import { inputBaseClasses } from '@mui/material/InputBase';

 MuiInputBase: {
   styleOverrides: {
     root: {
-      [`& .${inputBaseClasses.inputSizeSmall}`]: {
+      [`&.${inputBaseClasses.sizeSmall} > .${inputBaseClasses.input}`]: {
         color: 'red',
       },
     },
   },
 }

components → slots, componentsProps → slotProps로도 대체됐어요.

 <InputBase
-  components={{ Input: CustomInput, Root: CustomRoot }}
-  componentsProps={{ input: { id: 'test-input-id' }, root: { id: 'test-root-id' } }}
+  slots={{ input: CustomInput, root: CustomRoot }}
+  slotProps={{ input: { id: 'test-input-id' }, root: { id: 'test-root-id' } }}
 />

ListItem

npx @mui/codemod@latest deprecations/list-item-props <path>

components → slots, componentsProps → slotProps, ContainerComponent → slots.root 또는 component, ContainerProps → slotProps.root로 대체됐어요.

 <ListItem
-  components={{ Root: CustomRoot }}
-  componentsProps={{ root: { id: 'root-id' } }}
-  ContainerComponent={CustomContainer}
-  ContainerProps={{ id: 'container-id' }}
+  slots={{ root: CustomContainer }}
+  slotProps={{ root: { id: 'container-id' } }}
 />

ListItemSecondaryAction (deprecated 컴포넌트)

ListItemSecondaryAction 컴포넌트는 ListItem 컴포넌트의 secondaryAction prop으로 대체됐어요.

 <ListItem
+  secondaryAction={
+    <IconButton aria-label="Leave a comment">
+      <CommentIcon />
+    </IconButton>
+  }
   disablePadding
 >
   <ListItemButton>
     <ListItemText primary="John Doe" />
   </ListItemButton>
-  <ListItemSecondaryAction>
-    <IconButton aria-label="Leave a comment">
-      <CommentIcon />
-    </IconButton>
-  </ListItemSecondaryAction>
 </ListItem>

ListItemText

npx @mui/codemod@latest deprecations/list-item-text-props <path>

primaryTypographyProps → slotProps.primary, secondaryTypographyProps → slotProps.secondary로 대체됐어요.

 <ListItemText
-  primaryTypographyProps={primaryTypographyProps}
-  secondaryTypographyProps={secondaryTypographyProps}
+  slotProps={{ primary: primaryTypographyProps, secondary: secondaryTypographyProps }}
 />

ImageListItemBar

npx @mui/codemod@latest deprecations/image-list-item-bar-classes <path>

position·actionPosition prop과 titleWrap·actionIcon 클래스를 조합한 클래스가 deprecated됐어요.

-.MuiImageListItemBar-titleWrapBelow
+.MuiImageListItemBar-positionBelow > .MuiImageListItemBar-titleWrap
-.MuiImageListItemBar-titleWrapActionPosLeft
+.MuiImageListItemBar-actionPositionLeft > .MuiImageListItemBar-titleWrap
-.MuiImageListItemBar-actionIconActionPosLeft
+.MuiImageListItemBar-actionPositionLeft > .MuiImageListItemBar-actionIcon

LinearProgress

npx @mui/codemod@latest deprecations/linear-progress-classes <path>

variant·color prop을 조합한 클래스가 deprecated됐어요.

-.MuiLinearProgress-bar1Buffer
+.MuiLinearProgress-buffer > .MuiLinearProgress-bar1
-.MuiLinearProgress-bar1Indeterminate
+.MuiLinearProgress-indeterminate > .MuiLinearProgress-bar1
-.MuiLinearProgress-barColorPrimary
+.MuiLinearProgress-colorPrimary > .MuiLinearProgress-bar
-.MuiLinearProgress-dashedColorSecondary
+.MuiLinearProgress-colorSecondary > .MuiLinearProgress-dashed
 import { linearProgressClasses } from '@mui/material/LinearProgress';

 MuiLinearProgress: {
   styleOverrides: {
     root: {
-      [`&.${linearProgressClasses.bar1Determinate}`]: {},
+      [`&.${linearProgressClasses.determinate} > .${linearProgressClasses.bar1}`]: {},
     },
   },
 }
npx @mui/codemod@latest deprecations/menu-props <path>

MenuListProps → slotProps.list, TransitionProps → slotProps.transition로 대체됐어요.

 <Menu
-  MenuListProps={menuListProps}
-  TransitionProps={transitionProps}
+  slotProps={{ list: menuListProps, transition: transitionProps }}
 >

MobileStepper

npx @mui/codemod@latest deprecations/mobile-stepper-props <path>

LinearProgressProps → slotProps.progress로 대체됐어요.

 <MobileStepper
-  LinearProgressProps={{ color: 'primary' }}
+  slotProps={{ progress: { color: 'primary' } }}
 />
npx @mui/codemod@latest deprecations/modal-props <path>

components → slots, componentsProps → slotProps, BackdropProps → slotProps.backdrop, BackdropComponent → slots.backdrop로 대체됐어요.

 <Modal
-  components={{ Root: CustomRoot, Backdrop: CustomBackdrop }}
-  componentsProps={{ root: { id: 'root-id' }, backdrop: { id: 'backdrop-id' } }}
-  BackdropProps={{ timeout: 500 }}
-  BackdropComponent={Backdrop}
+  slots={{ root: CustomRoot, backdrop: CustomBackdrop }}
+  slotProps={{ root: { id: 'root-id' }, backdrop: { id: 'backdrop-id', timeout: 500 } }}
 >

PaginationItem

npx @mui/codemod@latest deprecations/pagination-item-classes <path>

variant·color를 조합한 클래스가 제거되고, components → slots로 대체됐어요.

-.MuiPaginationItem-textPrimary
+.MuiPaginationItem-text.MuiPaginationItem-colorPrimary
-.MuiPaginationItem-outlinedSecondary
+.MuiPaginationItem-outlined.MuiPaginationItem-colorSecondary
 import { paginationItemClasses } from '@mui/material/PaginationItem';

 MuiPaginationItem: {
   styleOverrides: {
     root: {
-      [`&.${paginationItemClasses.textPrimary}`]: {
+      [`&.${paginationItemClasses.text}.${paginationItemClasses.colorPrimary}`]: {
         color: 'red',
       },
     },
   },
 }
 <PaginationItem
-  components={{ first: FirstIcon, last: LastIcon, previous: PreviousIcon, next: NextIcon }}
+  slots={{ first: FirstIcon, last: LastIcon, previous: PreviousIcon, next: NextIcon }}
 />

Popover

npx @mui/codemod@latest deprecations/popover-props <path>

BackdropComponent → slots.backdrop, BackdropProps → slotProps.backdrop, PaperProps → slotProps.paper, TransitionComponent → slots.transition, TransitionProps → slotProps.transition로 대체됐어요.

 <Popover
-  BackdropComponent={Backdrop}
-  BackdropProps={{ timeout: 500 }}
-  PaperProps={{ id: 'paper-id' }}
-  TransitionComponent={Transition}
-  TransitionProps={{ timeout: 500 }}
+  slots={{ backdrop: Backdrop, transition: Transition }}
+  slotProps={{ backdrop: { timeout: 500 }, paper: { id: 'paper-id' }, transition: { timeout: 500 } }}
 >

Popper

npx @mui/codemod@latest deprecations/popper-props <path>

components → slots, componentsProps → slotProps로 대체됐어요.

 <Popper
-  components={{ Root: CustomRoot }}
-  componentsProps={{ root: { id: 'root-id' } }}
+  slots={{ root: CustomRoot }}
+  slotProps={{ root: { id: 'root-id' } }}
 />

Rating

npx @mui/codemod@latest deprecations/rating-props <path>

IconContainerComponent → slotProps.icon.component로 대체됐어요.

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

Select

npx @mui/codemod@latest deprecations/select-classes <path>

icon 클래스와 variant prop을 조합한 클래스가 제거됐어요.

- .MuiSelect-iconFilled
+ .MuiSelect-filled ~ .MuiSelect-icon
- .MuiSelect-iconOutlined
+ .MuiSelect-outlined ~ .MuiSelect-icon
- .MuiSelect-iconStandard
+ .MuiSelect-standard ~ .MuiSelect-icon
 import { selectClasses } from '@mui/material/Select';

 MuiSelect: {
   styleOverrides: {
     root: {
-      [`& .${selectClasses.iconFilled}`]: {
+      [`& .${selectClasses.filled} ~ .${selectClasses.icon}`]: {
         color: 'red',
       },
     },
   },
 }

Slider

npx @mui/codemod@latest deprecations/slider-props <path>
npx @mui/codemod@latest deprecations/slider-classes <path>

color·size prop을 조합한 클래스가 제거되고, components → slots, componentsProps → slotProps로 대체됐어요.

-.MuiSlider-root .MuiSlider-thumbSizeSmall
+.MuiSlider-root.MuiSlider-sizeSmall > .MuiSlider-thumb
-.MuiSlider-root .MuiSlider-thumbColorPrimary
+.MuiSlider-root.MuiSlider-colorPrimary > .MuiSlider-thumb
 import { sliderClasses } from '@mui/material/Slider';

 MuiSlider: {
   styleOverrides: {
     root: {
-      [`& .${sliderClasses.thumbColorSecondary}`]: {
+      [`&.${sliderClasses.colorSecondary} > .${sliderClasses.thumb}`]: {
         color: 'red',
       },
     },
   },
 }
 <Slider
-  components={{ Track: CustomTrack }}
-  componentsProps={{ track: { id: 'track-id' } }}
+  slots={{ track: CustomTrack }}
+  slotProps={{ track: { id: 'track-id' } }}
 />

SwipeableDrawer

npx @mui/codemod@latest deprecations/drawer-props <path>

BackdropProps → slotProps.backdrop, PaperProps → slotProps.paper, SlideProps → slotProps.transition로 대체됐어요.

 <SwipeableDrawer
-  BackdropProps={backdropProps}
-  PaperProps={paperProps}
-  SlideProps={slideProps}
+  slotProps={{ backdrop: backdropProps, paper: paperProps, transition: slideProps }}
 />

ToggleButtonGroup

npx @mui/codemod@latest deprecations/toggle-button-group-classes <path>

orientation prop과 grouped CSS 클래스를 조합한 클래스가 제거됐어요.

-.MuiToggleButtonGroup-root .MuiToggleButtonGroup-groupedHorizontal
+.MuiToggleButtonGroup-root.MuiToggleButtonGroup-horizontal > .MuiToggleButtonGroup-grouped
-.MuiToggleButtonGroup-root .MuiToggleButtonGroup-groupedVertical
+.MuiToggleButtonGroup-root.MuiToggleButtonGroup-vertical > .MuiToggleButtonGroup-grouped
 import { toggleButtonGroupClasses } from '@mui/material/ToggleButtonGroup';

 MuiButtonGroup: {
   styleOverrides: {
     root: {
-      [`& .${toggleButtonGroupClasses.groupedHorizontal}`]: {
+      [`&.${toggleButtonGroupClasses.horizontal} > .${toggleButtonGroupClasses.grouped}`]: {
         color: 'red',
       },
     },
   },
 }

Tabs

npx @mui/codemod@latest deprecations/tabs-classes <path>
npx @mui/codemod@latest deprecations/tabs-props <path>

flexContainer 클래스가 list로 대체되고, ScrollButtonComponent → slots.scrollButtons, TabScrollButtonProps → slotProps.scrollButtons, TabIndicatorProps → slotProps.indicator로 대체됐어요. 또 slots.StartScrollButtonIcon·slots.EndScrollButtonIcon은 camelCase인 slots.startScrollButtonIcon·slots.endScrollButtonIcon으로 바뀌었어요.

-.MuiTabs-flexContainer
+.MuiTabs-list
-.MuiTabs-flexContainerVertical
+.MuiTabs-list.MuiTabs-vertical
 import { tabsClasses } from '@mui/material/Tabs';

 MuiButtonGroup: {
   styleOverrides: {
     root: {
-      [`& .${tabsClasses.flexContainer}`]: {
+      [`& .${tabsClasses.list}`]: {
         color: 'red',
       },
     },
   },
 }
 <Tabs
-  ScrollButtonComponent={ScrollButtonComponent}
-  TabScrollButtonProps={TabScrollButtonProps}
-  TabIndicatorProps={TabIndicatorProps}
-  slots={{ StartScrollButtonIcon: StartScrollButtonIcon, EndScrollButtonIcon: EndScrollButtonIcon }}
+  slots={{ scrollButtons: ScrollButtonComponent, startScrollButtonIcon: StartScrollButtonIcon, endScrollButtonIcon: EndScrollButtonIcon }}
+  slotProps={{ scrollButtons: TabScrollButtonProps, indicator: TabIndicatorProps }}
 />

Tab

npx @mui/codemod@latest deprecations/tab-classes <path>

iconWrapper 클래스가 제거됐어요.

- .MuiTab-iconWrapper
+ .MuiTab-icon
 import { tabClasses } from '@mui/material/Tab';

 MuiTab: {
   styleOverrides: {
     root: {
-      [`& .${tabClasses.iconWrapper}`]: {
+      [`& .${tabClasses.icon}`]: {
         color: 'red',
       },
     },
   },
 }

TableSortLabel

npx @mui/codemod@latest deprecations/table-sort-label-classes <path>

direction prop과 icon prop을 조합한 클래스가 제거됐어요.

-.MuiTableSortLabel-iconDirectionDesc
+.MuiTableSortLabel-directionDesc > .MuiTableSortLabel-icon
-.MuiTableSortLabel-iconDirectionAsc
+.MuiTableSortLabel-directionAsc > .MuiTableSortLabel-icon
 import { tableSortLabelClasses } from '@mui/material/TableSortLabel';

 MuiTableSortLabel: {
   styleOverrides: {
     root: {
-      [`& .${tableSortLabelClasses.iconDirectionDesc}`]: {
+      [`&.${tableSortLabelClasses.directionDesc} > .${tableSortLabelClasses.icon}`]: {
         color: 'red',
       },
     },
   },
 }

TextField

npx @mui/codemod@latest deprecations/text-field-props <path>

모든 슬롯 props(*Props)가 slotProps 항목으로 대체됐어요.

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

Tooltip

npx @mui/codemod@latest deprecations/tooltip-props <path>

components → slots, componentsProps → slotProps, 슬롯(*Component) prop → slots, 슬롯 props(*Props) → slotProps로 대체됐어요.

 <Tooltip
-  components={{ Arrow: CustomArrow }}
-  componentsProps={{ arrow: { id: 'arrow-id' } }}
-  PopperComponent={CustomPopperComponent}
-  TransitionComponent={CustomTransitionComponent}
-  PopperProps={CustomPopperProps}
-  TransitionProps={CustomTransitionProps}
+  slots={{ arrow: CustomArrow, popper: CustomPopperComponent, transition: CustomTransitionComponent }}
+  slotProps={{ arrow: { id: 'arrow-id' }, popper: CustomPopperProps, transition: CustomTransitionProps }}
 />

Typography

npx @mui/codemod@latest deprecations/typography-props <path>

paragraph prop이 deprecated됐어요. Typography를 쓸 때 p를 렌더링하고 싶다면 component="p"를 전달해요.

 <Typography
   variant="subtitle1"
-  paragraph
+  component="p"
 />

참고로 Typography는 기본적으로 p를 렌더링하므로 variant를 명시하지 않았다면 component="p"를 전달할 필요 없어요. 기본 variant가 body1이고, body1·body2 variant는 p를 렌더링하기 때문이에요. 기존에 paragraph를 쓸 때 자동으로 더해지던 16px의 margin-bottom은 이제 직접 처리해야 해요. paragraph prop을 제거하는 codemod는 Typography 컴포넌트에 sx={{ marginBottom: '16px' }}를 추가해줘요.

StepLabel

npx @mui/codemod@latest deprecations/step-label-props <path>

componentsProps → slotProps, StepIconComponent → slots.stepIcon, StepIconProps → slotProps.stepIcon로 대체됐어요.

 <StepLabel
-  componentsProps={{ label: labelProps }}
-  StepIconComponent={StepIconComponent}
-  StepIconProps={StepIconProps}
+  slots={{ stepIcon: StepIconComponent }}
+  slotProps={{ label: labelProps, stepIcon: StepIconProps }}
 />

StepConnector

npx @mui/codemod@latest deprecations/step-connector-classes <path>

line CSS 클래스와 orientation prop을 조합한 클래스가 제거됐어요.

-.MuiStepConnector-lineHorizontal
+.MuiStepConnector-horizontal > .MuiStepConnector-line
-.MuiStepConnector-lineVertical
+.MuiStepConnector-vertical > .MuiStepConnector-line
 import { stepConnectorClasses } from '@mui/material/StepConnector';

 MuiStepConnector: {
   styleOverrides: {
     root: {
-      [`& .${stepConnectorClasses.lineHorizontal}`]: {
+      [`&.${stepConnectorClasses.horizontal} > .${stepConnectorClasses.line}`]: {
         color: 'red',
       },
     },
   },
 }

StepContent

npx @mui/codemod@latest deprecations/step-content-props <path>

TransitionComponent → slots.transition, TransitionProps → slotProps.transition로 대체됐어요.

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

SpeedDial

npx @mui/codemod@latest deprecations/speed-dial-props <path>

TransitionComponent → slots.transition, TransitionProps → slotProps.transition로 대체됐어요.

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

SpeedDialAction

npx @mui/codemod@latest deprecations/speed-dial-action-props <path>

FabProps → slotProps.fab, TooltipClasses → slotProps.tooltip.classes, tooltipPlacement → slotProps.tooltip.placement, tooltipTitle → slotProps.tooltip.title, tooltipOpen → slotProps.tooltip.open로 대체됐어요.

 <SpeedDialAction
-  FabProps={CustomFabProps}
-  TooltipClasses={{ tooltip: 'foo' }}
-  tooltipPlacement="top"
-  tooltipTitle="foo"
-  tooltipOpen
+  slotProps={{ fab: CustomFabProps, tooltip: { classes: { tooltip: 'foo' }, placement: 'top', title: 'foo', open: true } }}
 />

더 알아보기 (Learn more)