Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[material-ui][ButtonGroup] Deprecate composed classes #41259

Merged
merged 20 commits into from
Mar 19, 2024
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,140 @@ Here's how to migrate:
},
```

## ButtonGroup

Use the [codemod](https://github.com/mui/material-ui/tree/HEAD/packages/mui-codemod#button-group-classes) below to migrate the code as described in the following sections:

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

### Composed CSS classes

The CSS classes that composed the following props were deprecated:

- `orientation` | `variant` and `grouped`
- `color`, `variant` and `grouped`

Here's how to migrate:

```diff
-.MuiButtonGroup-root .MuiButtonGroup-groupedHorizontal
+.MuiButtonGroup-root.MuiButtonGroup-horizontal > .MuiButtonGroup-grouped
-.MuiButtonGroup-root .MuiButtonGroup-groupedVertical
+.MuiButtonGroup-root.MuiButtonGroup-vertical > .MuiButtonGroup-grouped
-.MuiButtonGroup-root .MuiButtonGroup-groupedText
+.MuiButtonGroup-root.MuiButtonGroup-text > .MuiButtonGroup-grouped
-.MuiButtonGroup-root .MuiButtonGroup-groupedTextHorizontal
+.MuiButtonGroup-root.MuiButtonGroup-text.MuiButtonGroup-horizontal > .MuiButtonGroup-grouped
-.MuiButtonGroup-root .MuiButtonGroup-groupedTextVertical
+.MuiButtonGroup-root.MuiButtonGroup-text.MuiButtonGroup-vertical > .MuiButtonGroup-grouped
-.MuiButtonGroup-root .MuiButtonGroup-groupedTextPrimary
+.MuiButtonGroup-root.MuiButtonGroup-text.MuiButtonGroup-colorPrimary > .MuiButtonGroup-grouped
-.MuiButtonGroup-root .MuiButtonGroup-groupedTextSecondary
+.MuiButtonGroup-root.MuiButtonGroup-text.MuiButtonGroup-colorSecondary > .MuiButtonGroup-grouped
-.MuiButtonGroup-root .MuiButtonGroup-groupedOutlined
+.MuiButtonGroup-root.MuiButtonGroup-outlined > .MuiButtonGroup-grouped
-.MuiButtonGroup-root .MuiButtonGroup-groupedOutlinedHorizontal
+.MuiButtonGroup-root.MuiButtonGroup-outlined.MuiButtonGroup-horizontal > .MuiButtonGroup-grouped
-.MuiButtonGroup-root .MuiButtonGroup-groupedOutlinedVertical
+.MuiButtonGroup-root.MuiButtonGroup-outlined.MuiButtonGroup-vertical > .MuiButtonGroup-grouped
-.MuiButtonGroup-root .MuiButtonGroup-groupedOutlinedPrimary
+.MuiButtonGroup-root.MuiButtonGroup-outlined.MuiButtonGroup-colorPrimary > .MuiButtonGroup-grouped
-.MuiButtonGroup-root .MuiButtonGroup-groupedOutlinedSecondary
+.MuiButtonGroup-root.MuiButtonGroup-outlined.MuiButtonGroup-colorSecondary > .MuiButtonGroup-grouped
-.MuiButtonGroup-root .MuiButtonGroup-groupedContained
+.MuiButtonGroup-root.MuiButtonGroup-contained > .MuiButtonGroup-grouped
-.MuiButtonGroup-root .MuiButtonGroup-groupedContainedHorizontal
+.MuiButtonGroup-root.MuiButtonGroup-contained.MuiButtonGroup-horizontal > .MuiButtonGroup-grouped
-.MuiButtonGroup-root .MuiButtonGroup-groupedContainedVertical
+.MuiButtonGroup-root.MuiButtonGroup-contained.MuiButtonGroup-vertical > .MuiButtonGroup-grouped
-.MuiButtonGroup-root .MuiButtonGroup-groupedContainedPrimary
+.MuiButtonGroup-root.MuiButtonGroup-contained.MuiButtonGroup-colorPrimary > .MuiButtonGroup-grouped
-.MuiButtonGroup-root .MuiButtonGroup-groupedContainedSecondary
+.MuiButtonGroup-root.MuiButtonGroup-contained.MuiButtonGroup-colorSecondary > .MuiButtonGroup-grouped
```

```diff

import { buttonGroupClasses } from '@mui/material/ButtonGroup';

MuiButtonGroup: {
styleOverrides: {
root: {
- [`& .${buttonGroupClasses.groupedHorizontal}`]: {
+ [`&.${buttonGroupClasses.horizontal} > .${buttonGroupClasses.grouped}`]: {
color: 'red',
},
- [`& .${buttonGroupClasses.groupedVertical}`]: {
+ [`&.${buttonGroupClasses.vertical} > .${buttonGroupClasses.grouped}`]: {
color: 'red',
},
- [`& .${buttonGroupClasses.groupedText}`]: {
+ [`&.${buttonGroupClasses.text} > .${buttonGroupClasses.grouped}`]: {
color: 'red',
},
- [`& .${buttonGroupClasses.groupedTextHorizontal}`]: {
+ [`&.${buttonGroupClasses.text}.${buttonGroupClasses.horizontal} > .${buttonGroupClasses.grouped}`]: {
color: 'red',
},
- [`& .${buttonGroupClasses.groupedTextVertical}`]: {
+ [`&.${buttonGroupClasses.text}.${buttonGroupClasses.vertical} > .${buttonGroupClasses.grouped}`]: {
color: 'red',
},
- [`& .${buttonGroupClasses.groupedTextPrimary}`]: {
+ [`&.${buttonGroupClasses.text}.${buttonGroupClasses.colorPrimary} > .${buttonGroupClasses.grouped}`]: {
color: 'red',
},
- [`& .${buttonGroupClasses.groupedTextSecondary}`]: {
+ [`&.${buttonGroupClasses.text}.${buttonGroupClasses.colorSecondary} > .${buttonGroupClasses.grouped}`]: {
color: 'red',
},
- [`& .${buttonGroupClasses.groupedOutlined}`]: {
+ [`&.${buttonGroupClasses.outlined} > .${buttonGroupClasses.grouped}`]: {
color: 'red',
},
- [`& .${buttonGroupClasses.groupedOutlinedHorizontal}`]: {
+ [`&.${buttonGroupClasses.outlined}.${buttonGroupClasses.horizontal} > .${buttonGroupClasses.grouped}`]: {
color: 'red',
},
- [`& .${buttonGroupClasses.groupedOutlinedVertical}`]: {
+ [`&.${buttonGroupClasses.outlined}.${buttonGroupClasses.vertical} > .${buttonGroupClasses.grouped}`]: {
color: 'red',
},
- [`& .${buttonGroupClasses.groupedOutlinedPrimary}`]: {
+ [`&.${buttonGroupClasses.outlined}.${buttonGroupClasses.colorPrimary} > .${buttonGroupClasses.grouped}`]: {
color: 'red',
},
- [`& .${buttonGroupClasses.groupedOutlinedSecondary}`]: {
+ [`&.${buttonGroupClasses.outlined}.${buttonGroupClasses.colorSecondary} > .${buttonGroupClasses.grouped}`]: {
color: 'red',
},
- [`& .${buttonGroupClasses.groupedContained}`]: {
+ [`&.${buttonGroupClasses.contained} > .${buttonGroupClasses.grouped}`]: {
color: 'red',
},
- [`& .${buttonGroupClasses.groupedContainedHorizontal}`]: {
+ [`&.${buttonGroupClasses.contained}.${buttonGroupClasses.horizontal} > .${buttonGroupClasses.grouped}`]: {
color: 'red',
},
- [`& .${buttonGroupClasses.groupedContainedVertical}`]: {
+ [`&.${buttonGroupClasses.contained}.${buttonGroupClasses.vertical} > .${buttonGroupClasses.grouped}`]: {
color: 'red',
},
- [`& .${buttonGroupClasses.groupedContainedPrimary}`]: {
+ [`&.${buttonGroupClasses.contained}.${buttonGroupClasses.colorPrimary} > .${buttonGroupClasses.grouped}`]: {
color: 'red',
},
- [`& .${buttonGroupClasses.groupedContainedSecondary}`]: {
+ [`&.${buttonGroupClasses.contained}.${buttonGroupClasses.colorSecondary} > .${buttonGroupClasses.grouped}`]: {
color: 'red',
},
},
},

```

## Chip

Use the [codemod](https://github.com/mui/material-ui/tree/HEAD/packages/mui-codemod#chip-classes) below to migrate the code as described in the following sections:
Expand Down
67 changes: 51 additions & 16 deletions docs/pages/material-ui/api/button-group.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@
"import { ButtonGroup } from '@mui/material';"
],
"classes": [
{
"key": "colorPrimary",
"className": "MuiButtonGroup-colorPrimary",
"description": "Styles applied to the root element if `color=\"primary\"`",
"isGlobal": false
},
{
"key": "colorSecondary",
"className": "MuiButtonGroup-colorSecondary",
"description": "Styles applied to the root element if `color=\"secondary\"`",
"isGlobal": false
},
{
"key": "contained",
"className": "MuiButtonGroup-contained",
Expand Down Expand Up @@ -87,102 +99,125 @@
"key": "groupedContained",
"className": "MuiButtonGroup-groupedContained",
"description": "Styles applied to the children if `variant=\"contained\"`.",
"isGlobal": false
"isGlobal": false,
"isDeprecated": true
},
{
"key": "groupedContainedHorizontal",
"className": "MuiButtonGroup-groupedContainedHorizontal",
"description": "Styles applied to the children if `variant=\"contained\"` and `orientation=\"horizontal\"`.",
"isGlobal": false
"isGlobal": false,
"isDeprecated": true
},
{
"key": "groupedContainedPrimary",
"className": "MuiButtonGroup-groupedContainedPrimary",
"description": "Styles applied to the children if `variant=\"contained\"` and `color=\"primary\"`.",
"isGlobal": false
"isGlobal": false,
"isDeprecated": true
},
{
"key": "groupedContainedSecondary",
"className": "MuiButtonGroup-groupedContainedSecondary",
"description": "Styles applied to the children if `variant=\"contained\"` and `color=\"secondary\"`.",
"isGlobal": false
"isGlobal": false,
"isDeprecated": true
},
{
"key": "groupedContainedVertical",
"className": "MuiButtonGroup-groupedContainedVertical",
"description": "Styles applied to the children if `variant=\"contained\"` and `orientation=\"vertical\"`.",
"isGlobal": false
"isGlobal": false,
"isDeprecated": true
},
{
"key": "groupedHorizontal",
"className": "MuiButtonGroup-groupedHorizontal",
"description": "Styles applied to the children if `orientation=\"horizontal\"`.",
"isGlobal": false
"isGlobal": false,
"isDeprecated": true
},
{
"key": "groupedOutlined",
"className": "MuiButtonGroup-groupedOutlined",
"description": "Styles applied to the children if `variant=\"outlined\"`.",
"isGlobal": false
"isGlobal": false,
"isDeprecated": true
},
{
"key": "groupedOutlinedHorizontal",
"className": "MuiButtonGroup-groupedOutlinedHorizontal",
"description": "Styles applied to the children if `variant=\"outlined\"` and `orientation=\"horizontal\"`.",
"isGlobal": false
"isGlobal": false,
"isDeprecated": true
},
{
"key": "groupedOutlinedPrimary",
"className": "MuiButtonGroup-groupedOutlinedPrimary",
"description": "Styles applied to the children if `variant=\"outlined\"` and `color=\"primary\"`.",
"isGlobal": false
"isGlobal": false,
"isDeprecated": true
},
{
"key": "groupedOutlinedSecondary",
"className": "MuiButtonGroup-groupedOutlinedSecondary",
"description": "Styles applied to the children if `variant=\"outlined\"` and `color=\"secondary\"`.",
"isGlobal": false
"isGlobal": false,
"isDeprecated": true
},
{
"key": "groupedOutlinedVertical",
"className": "MuiButtonGroup-groupedOutlinedVertical",
"description": "Styles applied to the children if `variant=\"outlined\"` and `orientation=\"vertical\"`.",
"isGlobal": false
"isGlobal": false,
"isDeprecated": true
},
{
"key": "groupedText",
"className": "MuiButtonGroup-groupedText",
"description": "Styles applied to the children if `variant=\"text\"`.",
"isGlobal": false
"isGlobal": false,
"isDeprecated": true
},
{
"key": "groupedTextHorizontal",
"className": "MuiButtonGroup-groupedTextHorizontal",
"description": "Styles applied to the children if `variant=\"text\"` and `orientation=\"horizontal\"`.",
"isGlobal": false
"isGlobal": false,
"isDeprecated": true
},
{
"key": "groupedTextPrimary",
"className": "MuiButtonGroup-groupedTextPrimary",
"description": "Styles applied to the children if `variant=\"text\"` and `color=\"primary\"`.",
"isGlobal": false
"isGlobal": false,
"isDeprecated": true
},
{
"key": "groupedTextSecondary",
"className": "MuiButtonGroup-groupedTextSecondary",
"description": "Styles applied to the children if `variant=\"text\"` and `color=\"secondary\"`.",
"isGlobal": false
"isGlobal": false,
"isDeprecated": true
},
{
"key": "groupedTextVertical",
"className": "MuiButtonGroup-groupedTextVertical",
"description": "Styles applied to the children if `variant=\"text\"` and `orientation=\"vertical\"`.",
"isGlobal": false
"isGlobal": false,
"isDeprecated": true
},
{
"key": "groupedVertical",
"className": "MuiButtonGroup-groupedVertical",
"description": "Styles applied to the children if `orientation=\"vertical\"`.",
"isGlobal": false,
"isDeprecated": true
},
{
"key": "horizontal",
"className": "MuiButtonGroup-horizontal",
"description": "Styles applied to the root element if `orientation=\"horizontal\"`.",
"isGlobal": false
},
{
Expand Down
Loading
Loading