Skip to content

Commit

Permalink
Add section to upgrade to v7 guide
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoAndai committed Feb 21, 2025
1 parent ec5cc19 commit 1d0234c
Showing 1 changed file with 63 additions and 30 deletions.
93 changes: 63 additions & 30 deletions docs/data/material/migration/upgrade-to-v7/upgrade-to-v7.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,38 +69,71 @@ If you were using a Vite alias to force ESM imports for the icons package, you s
},
```

### Grid renamed to GridLegacy
### Grid and Grid2 renamed

The deprecated `Grid` component has been renamed to `GridLegacy`.
If you wish to continue using this legacy component, update your imports as follows:

```diff
-import Grid, { gridClasses, GridProps } from '@mui/material/Grid';
+import Grid, { gridLegacyClasses, GridLegacyProps } from '@mui/material/GridLegacy';

-import { Grid } from '@mui/material';
+import { GridLegacy as Grid } from '@mui/material';
```

This also applies to the theme's `components` object:

```diff
const theme = createTheme({
components: {
- MuiGrid: {
+ MuiGridLegacy: {
// ...
},
},
});
```

As well as the component's CSS classes:

```diff
-.MuiGrid-root
+.MuiGridLegacy-root
```
The `Grid2` component has been moved to the `Grid` namespace.
Depending on your project, you may follow one of the following approaches:

1. **If you are using the deprecated grid and wish to upgrade,** run the following codemod:

<!-- #npm-tag-reference -->

```bash
npx @mui/codemod@next v7.0.0/grid-props <path/to/folder>
```

See the [Grid upgrade guide](/material-ui/migration/upgrade-to-grid-v2/) for more information.

2. **If you are using the deprecated grid and wish to continue using it,** update the `Grid` references as follows:

```diff
// imports
-import Grid, { gridClasses, GridProps } from '@mui/material/Grid';
+import Grid, { gridLegacyClasses, GridLegacyProps } from '@mui/material/GridLegacy';

-import { Grid } from '@mui/material';
+import { GridLegacy as Grid } from '@mui/material';

// theme
const theme = createTheme({
components: {
- MuiGrid: {
+ MuiGridLegacy: {
// ...
},
},
});

// CSS classes
-.MuiGrid-root
+.MuiGridLegacy-root
```

3. **If you are using Grid2,** update the `Grid2` references as follows:

```diff
// imports
-import Grid, { grid2Classes as gridClasses, Grid2Props as GridProps } from '@mui/material/Grid2';
+import Grid, { gridClasses, GridProps } from '@mui/material/Grid';

-import { Grid2 as Grid } from '@mui/material';
+import { Grid } from '@mui/material';

// theme
const theme = createTheme({
components: {
- MuiGrid2: {
+ MuiGrid: {
// ...
},
},
});

// CSS classes
-.MuiGrid2-root
+.MuiGrid-root
```

### Hidden and PigmentHidden components removed

Expand Down

0 comments on commit 1d0234c

Please sign in to comment.