diff --git a/examples/material-ui-nextjs-ts/src/app/layout.tsx b/examples/material-ui-nextjs-ts/src/app/layout.tsx
index f415c91852f467..bc84111b3abd99 100644
--- a/examples/material-ui-nextjs-ts/src/app/layout.tsx
+++ b/examples/material-ui-nextjs-ts/src/app/layout.tsx
@@ -3,15 +3,19 @@ import { AppRouterCacheProvider } from '@mui/material-nextjs/v14-appRouter';
import { ThemeProvider } from '@mui/material/styles';
import CssBaseline from '@mui/material/CssBaseline';
import theme from '@/theme';
+import InitColorSchemeScript from '@mui/material/InitColorSchemeScript';
+import ModeSwitch from '@/components/ModeSwitch';
export default function RootLayout(props: { children: React.ReactNode }) {
return (
-
+
+
{/* CssBaseline kickstart an elegant, consistent, and simple baseline to build upon. */}
+
{props.children}
diff --git a/examples/material-ui-nextjs-ts/src/components/ModeSwitch.tsx b/examples/material-ui-nextjs-ts/src/components/ModeSwitch.tsx
new file mode 100644
index 00000000000000..4f664645efd1ce
--- /dev/null
+++ b/examples/material-ui-nextjs-ts/src/components/ModeSwitch.tsx
@@ -0,0 +1,40 @@
+'use client';
+import * as React from 'react';
+import Box from '@mui/material/Box';
+import FormControl from '@mui/material/FormControl';
+import InputLabel from '@mui/material/InputLabel';
+import MenuItem from '@mui/material/MenuItem';
+import Select from '@mui/material/Select';
+import { useColorScheme } from '@mui/material/styles';
+
+export default function ModeSwitch() {
+ const { mode, setMode } = useColorScheme();
+ if (!mode) {
+ return null;
+ }
+ return (
+
+
+ Theme
+
+
+
+ );
+}
diff --git a/examples/material-ui-nextjs-ts/src/theme.ts b/examples/material-ui-nextjs-ts/src/theme.ts
index b42a2821c83698..bb71ad797df304 100644
--- a/examples/material-ui-nextjs-ts/src/theme.ts
+++ b/examples/material-ui-nextjs-ts/src/theme.ts
@@ -9,9 +9,9 @@ const roboto = Roboto({
});
const theme = createTheme({
- cssVariables: true,
- palette: {
- mode: 'light',
+ colorSchemes: { light: true, dark: true },
+ cssVariables: {
+ colorSchemeSelector: 'class',
},
typography: {
fontFamily: roboto.style.fontFamily,