diff --git a/packages/mui-material/src/styles/ThemeProviderNoVars.tsx b/packages/mui-material/src/styles/ThemeProviderNoVars.tsx index a7e78f37536c56..ef012daec93118 100644 --- a/packages/mui-material/src/styles/ThemeProviderNoVars.tsx +++ b/packages/mui-material/src/styles/ThemeProviderNoVars.tsx @@ -8,11 +8,25 @@ export interface ThemeProviderNoVarsProps { theme: Partial | ((outerTheme: Theme) => Theme); } +let warnedOnceNoSsr = false; + export default function ThemeProviderNoVars({ theme: themeInput, ...props }: ThemeProviderNoVarsProps): React.ReactElement> { const scopedTheme = THEME_ID in themeInput ? themeInput[THEME_ID] : undefined; + if (process.env.NODE_ENV !== 'production') { + // @ts-ignore + if (process.env.NODE_ENV !== 'test' && props.noSsr && !warnedOnceNoSsr) { + console.error( + [ + 'MUI: The `noSsr` prop must be used with the theme that contains light and dark colorSchemes.', + 'See https://mui.com/material-ui/customization/dark-mode/#built-in-support for more details.', + ].join('\n'), + ); + warnedOnceNoSsr = true; + } + } return (