[button] Remove deprecated classes by silviuaavram · Pull Request #48012 · mui/material-ui (original) (raw)
- I have followed (at least) the PR section of the contributing guide.
Copilot AI review requested due to automatic review settings
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR removes deprecated Button utility CSS classes (e.g. textPrimary, outlinedSizeSmall, iconSizeSmall) from the Material UI Button implementation and updates the API docs/tests/migration guide to reflect the new “combine base classes” approach (e.g. .MuiButton-text.MuiButton-colorPrimary).
Changes:
- Remove deprecated
Buttonclass keys frombuttonClassesand stop generating/applying them inButton. - Update
Buttonunit tests to assert the remaining non-deprecated class names (color*,size*,text|outlined|contained). - Remove deprecated class entries from the generated API docs JSON and add an upgrade-to-v9 migration section for the removals.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/mui-material/src/Button/buttonClasses.ts | Drops deprecated class keys from the public buttonClasses contract and utility class generation list. |
| packages/mui-material/src/Button/Button.js | Stops composing deprecated variant+color / variant+size / iconSize* utility classes and removes them from overrides resolvers. |
| packages/mui-material/src/Button/Button.test.js | Updates assertions to use color* and size* classes instead of deprecated combined class names. |
| docs/translations/api-docs/button/button.json | Removes deprecated class descriptions from translated API docs data. |
| docs/pages/material-ui/api/button.json | Removes deprecated class entries from the generated Button API page JSON. |
| docs/data/material/migration/upgrade-to-v9/upgrade-to-v9.md | Adds an upgrade note listing removed deprecated Button classes and suggested replacements. |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Removes deprecated Button CSS utility classes from the Material UI codebase as part of the v9 upgrade path, and updates tests/docs to reflect the new class composition approach (variant + color/size classes combined via selectors rather than dedicated “combined” class keys).
Changes:
- Remove deprecated
Buttonclass keys frombuttonClassesand stop generating them inButton’s utility classes / overrides resolvers. - Update
ButtonandButtonGrouptests to assert non-deprecated classes (outlined,colorPrimary,sizeSmall, etc.). - Remove deprecated class entries from the Button API docs and add an upgrade-to-v9 migration note listing the removed classes and replacements.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/mui-material/src/ButtonGroup/ButtonGroup.test.js | Updates assertions to use non-deprecated Button classes. |
| packages/mui-material/src/Button/buttonClasses.ts | Removes deprecated class keys from the ButtonClasses interface and generated utility classes. |
| packages/mui-material/src/Button/Button.test.js | Rewrites tests to validate variant + color*/size* classes instead of deprecated combined classes. |
| packages/mui-material/src/Button/Button.js | Stops emitting deprecated combined utility classes and removes them from overrides resolution paths. |
| docs/translations/api-docs/button/button.json | Removes deprecated class descriptions from translated Button API docs. |
| docs/pages/material-ui/api/button.json | Removes deprecated class entries from the Button API page data. |
| docs/data/material/migration/upgrade-to-v9/upgrade-to-v9.md | Adds v9 upgrade guidance for removed deprecated Button classes and codemod usage. |
Comments suppressed due to low confidence (1)
packages/mui-material/src/Button/Button.js:91
ButtonRoot'soverridesResolverno longer includesstyles.colorPrimary/styles.colorSecondary/etc. As a result, themecomponents.MuiButton.styleOverrides.color*entries won't be applied even though the corresponding utility classes are still generated on the root element. Includestyles[color${capitalize(ownerState.color)}](and optionally drop the special-casing forinherit) so color-based style overrides keep working after removing the deprecated variant+color classes.
return [
styles.root,
styles[ownerState.variant],
styles[`size${capitalize(ownerState.size)}`],
ownerState.color === 'inherit' && styles.colorInherit,
ownerState.disableElevation && styles.disableElevation,
ownerState.fullWidth && styles.fullWidth,
ownerState.loading && styles.loading,
];
| npx @mui/codemod@latest deprecations/button-classes |
|---|
| ``` |
| The following deprecated `Button` CSS classes have been removed: |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we are removing classes, we are also removing the keys in the theme overrides styles key. These are a bit of an "older" API but still valid. Should we mention these as breaking changes too? cc @siriwatknp
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})