Skip to content

[Rating] Remove deprecated IconContainerComponent#48019

Merged
mj12albert merged 6 commits intomui:masterfrom
siriwatknp:remove-deprecated-rating-props
Mar 23, 2026
Merged

[Rating] Remove deprecated IconContainerComponent#48019
mj12albert merged 6 commits intomui:masterfrom
siriwatknp:remove-deprecated-rating-props

Conversation

@siriwatknp
Copy link
Copy Markdown
Member

Summary

Remove the deprecated IconContainerComponent prop from the Rating component.

Breaking change

The IconContainerComponent prop has been removed. Use slotProps.icon.component instead:

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

Use the rating-props codemod for automated migration:

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

Changes

  • Removed IconContainerComponent from component source, types, and PropTypes
  • Updated RadioGroupRating demo to use slotProps.icon.component
  • Added migration guide entry in upgrade-to-v9.md
  • Regenerated API docs via pnpm proptypes && pnpm docs:api

Test plan

  • pnpm prettier passes
  • pnpm eslint passes
  • pnpm typescript passes
  • pnpm test:unit Rating passes (49 tests)

@siriwatknp siriwatknp added breaking change Introduces changes that are not backward compatible. package: material-ui Specific to Material UI. labels Mar 18, 2026
@mui-bot
Copy link
Copy Markdown

mui-bot commented Mar 18, 2026

Netlify deploy preview

Bundle size report

Bundle Parsed size Gzip size
@mui/material ▼-102B(-0.02%) 🔺+29B(+0.02%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes

Generated by 🚫 dangerJS against 923e72a

getLabelText = defaultLabelText,
highlightSelectedOnly = false,
icon = defaultIcon,
IconContainerComponent = IconContainer,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The IconContainer previously stripped the value, removing the component leaks it into the DOM (e.g. in the first demo

<label><span value="2" class="MuiRating-icon"><svg /></span><span class="MuiRating-visuallyHidden">2 Stars</span></label>

We probably need to remove the value here now

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I almost feel like it's a different slot - iconContainer that receives the value and maybe the icon and renders it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, new test added to ensure the behavior

Copy link
Copy Markdown
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency, this should be slots.iconContainer, no?

It's a bit confusing, when do you use slots.icon vs slots.icon.component?

@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Mar 18, 2026
@zannager zannager added the scope: rating Changes related to the rating. label Mar 18, 2026
Use internalForwardedProps with IconContainer to strip value from DOM spread. Add test to verify.
…-rating-props

# Conflicts:
#	docs/data/material/migration/upgrade-to-v9/upgrade-to-v9.md
@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Mar 19, 2026
@siriwatknp
Copy link
Copy Markdown
Member Author

siriwatknp commented Mar 19, 2026

For consistency, this should be slots.iconContainer, no?

Ideally, yes but I would NOT change it right now. It's the old name before slots was added. Changing it right now will impact the theming too.

It's a bit confusing, when do you use slots.icon vs slots.icon.component?

In this case using slots.icon.component is correct to preserve the same behavior to IconContainerComponent.

  • slots.icon: will replace the styled-component RatingIcon, meaning you own the styles
  • slotProps.icon.component: inject the custom React component by preserving the slot styles (from MUI). This is the prior behavior of the Rating, so that's why the migration guide is different than other components.

@mj12albert
Copy link
Copy Markdown
Member

mj12albert commented Mar 19, 2026

slots.icon.component

We're talking about slotProps.icon.component and not slots right? (icon.component isn't a slot?)

i.e. the IconContainerComponent prop is now the "component prop of the icon slot"

(the PR looks good to me, was just confused by this for a sec)

@siriwatknp
Copy link
Copy Markdown
Member Author

siriwatknp commented Mar 19, 2026

slots.icon.component

We're talking about slotProps.icon.component and not slots right? (icon.component isn't a slot?)

i.e. the IconContainerComponent prop is now the "component prop of the icon slot"

(the PR looks good to me, was just confused by this for a sec)

Yes, correct (updated to slotProps.icon.component). The confusion was dictated by the logic of passing IconContainerComponent (a long time ago, even before the slots/slotProps).

@siriwatknp siriwatknp requested a review from mnajdova March 19, 2026 08:29
@siriwatknp
Copy link
Copy Markdown
Member Author

@mnajdova Is the explanation clear to you? anything I missed.

@mj12albert mj12albert enabled auto-merge (squash) March 23, 2026 06:19
@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Mar 23, 2026
…-rating-props

# Conflicts:
#	docs/data/material/migration/upgrade-to-v9/upgrade-to-v9.md
@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Mar 23, 2026
@mj12albert mj12albert merged commit e0293aa into mui:master Mar 23, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Introduces changes that are not backward compatible. package: material-ui Specific to Material UI. scope: rating Changes related to the rating.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants