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][styles] Remove deprecated exports #45397

Merged
merged 2 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { experimentalStyled as styled } from '@mui/material/styles';
import { styled } from '@mui/material/styles';
import Box from '@mui/material/Box';
import Paper from '@mui/material/Paper';
import Grid from '@mui/material/GridLegacy';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { experimentalStyled as styled } from '@mui/material/styles';
import { styled } from '@mui/material/styles';
import Box from '@mui/material/Box';
import Paper from '@mui/material/Paper';
import Grid from '@mui/material/GridLegacy';
Expand Down
2 changes: 1 addition & 1 deletion docs/data/material/components/grid/ResponsiveGrid.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { experimentalStyled as styled } from '@mui/material/styles';
import { styled } from '@mui/material/styles';
import Box from '@mui/material/Box';
import Paper from '@mui/material/Paper';
import Grid from '@mui/material/Grid';
Expand Down
2 changes: 1 addition & 1 deletion docs/data/material/components/grid/ResponsiveGrid.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { experimentalStyled as styled } from '@mui/material/styles';
import { styled } from '@mui/material/styles';
import Box from '@mui/material/Box';
import Paper from '@mui/material/Paper';
import Grid from '@mui/material/Grid';
Expand Down
30 changes: 30 additions & 0 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,6 +69,26 @@ If you were using a Vite alias to force ESM imports for the icons package, you s
},
```

### createMuiTheme removed

The deprecated `createMuiTheme` function has been removed.
Use `createTheme` instead.

```diff
-import { createMuiTheme } from '@mui/material/styles';
+import { createTheme } from '@mui/material/styles';
```

### experimentalStyled removed

The deprecated `experimentalStyled` function has been removed.
Use `styled` instead.

```diff
-import { experimentalStyled as styled } from '@mui/material/styles';
+import { styled } from '@mui/material/styles';
```

### Grid and Grid2 renamed

The deprecated `Grid` component has been renamed to `GridLegacy`.
Expand Down Expand Up @@ -228,3 +248,13 @@ npx @mui/codemod@next v7.0.0/input-label-size-normal-medium <path/to/folder>
### Removal of `data-testid` prop from `SvgIcon`

The default `data-testid` prop has been removed from the icons in `@mui/icons-material` in production bundles. This change ensures that the `data-testid` prop is only defined where needed, reducing the potential for naming clashes and removing unnecessary properties in production.

### StyledEngineProvider deprecated import path removed

Importing `StyledEngineProvider` from `'@mui/material'` was deprecated and now has been removed.
Import it from `'@mui/material/styles'` instead:

```diff
-import { StyledEngineProvider } from '@mui/material';
+import { StyledEngineProvider } from '@mui/material/styles';
```
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { experimentalStyled as styled } from '@mui/material/styles';
import { styled } from '@mui/material/styles';
import MuiButton from '@mui/material/Button';

const ButtonRoot = styled(MuiButton)(({ theme }) => ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { experimentalStyled as styled } from '@mui/material/styles';
import { styled } from '@mui/material/styles';
import MuiButton, { ButtonProps } from '@mui/material/Button';

const ButtonRoot = styled(MuiButton)(({ theme }) => ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import PropTypes from 'prop-types';
import { experimentalStyled as styled } from '@mui/material/styles';
import { styled } from '@mui/material/styles';

import Typography from '../components/Typography';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { experimentalStyled as styled, Theme } from '@mui/material/styles';
import { styled, Theme } from '@mui/material/styles';
import { SxProps } from '@mui/system';
import Typography from '../components/Typography';

Expand Down
4 changes: 0 additions & 4 deletions packages/mui-material/src/StyledEngineProvider/index.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/mui-material/src/StyledEngineProvider/index.js

This file was deleted.

5 changes: 0 additions & 5 deletions packages/mui-material/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,11 +457,6 @@ export * from './GlobalStyles';

export * from './version';

/**
* @deprecated will be removed in v5.beta, please use StyledEngineProvider from @mui/material/styles instead
*/
export { StyledEngineProvider } from './styles';

export { unstable_composeClasses } from '@mui/utils';

export { default as generateUtilityClass } from './generateUtilityClass';
Expand Down
1 change: 0 additions & 1 deletion packages/mui-material/src/styles/createTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import createThemeWithVars, {
} from './createThemeWithVars';
import createThemeNoVars, { Theme, ThemeOptions } from './createThemeNoVars';

export { createMuiTheme } from './createThemeNoVars';
export type { ThemeOptions, Theme, CssThemeVariables } from './createThemeNoVars';

// eslint-disable-next-line consistent-return
Expand Down
6 changes: 0 additions & 6 deletions packages/mui-material/src/styles/createThemeNoVars.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,6 @@ export interface Theme extends BaseTheme, CssVarsProperties {
unstable_sxConfig: SxConfig;
}

/**
* @deprecated
* Use `import { createTheme } from '@mui/material/styles'` instead.
*/
export function createMuiTheme(options?: ThemeOptions, ...args: object[]): Theme;

/**
* Generate a theme base on the options received.
* @param options Takes an incomplete theme object and adds the missing parts.
Expand Down
19 changes: 0 additions & 19 deletions packages/mui-material/src/styles/createThemeNoVars.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,23 +129,4 @@ function createThemeNoVars(options = {}, ...args) {
return muiTheme;
}

let warnedOnce = false;

export function createMuiTheme(...args) {
if (process.env.NODE_ENV !== 'production') {
if (!warnedOnce) {
warnedOnce = true;
console.error(
[
'MUI: the createMuiTheme function was renamed to createTheme.',
'',
"You should use `import { createTheme } from '@mui/material/styles'`",
].join('\n'),
);
}
}

return createThemeNoVars(...args);
}

export default createThemeNoVars;
5 changes: 0 additions & 5 deletions packages/mui-material/src/styles/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ export { default as THEME_ID } from './identifier';
export {
default as createTheme,
default as unstable_createMuiStrictModeTheme,
createMuiTheme,
ThemeOptions,
Theme,
CssThemeVariables,
Expand Down Expand Up @@ -78,10 +77,6 @@ export { default as useTheme } from './useTheme';
export { default as useThemeProps } from './useThemeProps';
export * from './useThemeProps';
export { default as styled } from './styled';
/**
* @deprecated will be removed in v5.beta, please use styled from @mui/material/styles instead
*/
export { default as experimentalStyled } from './styled';
export { default as ThemeProvider } from './ThemeProvider';
export { ComponentsProps, ComponentsPropsList } from './props';
export { ComponentsVariants } from './variants';
Expand Down
3 changes: 1 addition & 2 deletions packages/mui-material/src/styles/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function experimental_sx() {
'For more details, see /~https://github.com/mui/material-ui/pull/35150.',
);
}
export { default as createTheme, createMuiTheme } from './createTheme';
export { default as createTheme } from './createTheme';
export { default as unstable_createMuiStrictModeTheme } from './createMuiStrictModeTheme';
export { default as createStyles } from './createStyles';
export { getUnit as unstable_getUnit, toUnitless as unstable_toUnitless } from './cssUtils';
Expand All @@ -34,7 +34,6 @@ export { default as createColorScheme } from './createColorScheme';
export { default as useTheme } from './useTheme';
export { default as useThemeProps } from './useThemeProps';
export { default as styled } from './styled';
export { default as experimentalStyled } from './styled';
export { default as ThemeProvider } from './ThemeProvider';
export { StyledEngineProvider } from '@mui/system';
// The legacy utilities from @mui/styles
Expand Down