Settings
This section will describe how you settings your theme.
// src/App.(jsx | tsx) or src/app/layout.(jsx | tsx)
import { defaultSettings } from 'src/components/settings';
<SettingsProvider defaultSettings={defaultSettings}>
...
</SettingsProvider>
// src/App.(jsx | tsx) or src/app/layout.(jsx | tsx)
import { defaultSettings } from 'src/components/settings';
import { detectSettings } from 'src/components/settings/server';
export default async function RootLayout({ children }: RootLayoutProps) {
const cookieSettings = await detectSettings();
return (
<html lang="en" dir={cookieSettings.dir} suppressHydrationWarning>
<body>
<SettingsProvider cookieSettings={cookieSettings} defaultSettings={defaultSettings}>
...
</SettingsProvider>
</body>
</html>
);
}
// src/theme/create-theme.(js | ts)
export const baseTheme = {
colorSchemes: {
light: {
palette: palette.light,
shadows: shadows.light,
customShadows: customShadows.light
},
dark: {
palette: palette.dark,
shadows: shadows.dark,
customShadows: customShadows.dark
}
},
mixins,
components,
typography,
shape: { borderRadius: 8 },
direction: themeConfig.direction,
cssVariables: themeConfig.cssVariables,
defaultColorScheme: themeConfig.defaultMode
}
export function createTheme({ themeOverrides }) {
const theme = createMuiTheme(baseTheme, themeOverrides);
return theme;
}
// src/theme/create-theme.(js | ts)
export const baseTheme = {
colorSchemes: {
light: {
palette: palette.light,
shadows: shadows.light,
customShadows: customShadows.light
},
dark: {
palette: palette.dark,
shadows: shadows.dark,
customShadows: customShadows.dark
}
},
mixins,
components,
typography,
shape: { borderRadius: 8 },
direction: themeConfig.direction,
cssVariables: themeConfig.cssVariables,
defaultColorScheme: themeConfig.defaultMode
}
export function createTheme({ themeOverrides, localeComponents }) {
const theme = createMuiTheme(baseTheme, localeComponents, themeOverrides);
return theme;
}
// src/theme/create-theme.(js | ts)
export const baseTheme = {
colorSchemes: {
light: {
palette: palette.light,
shadows: shadows.light,
customShadows: customShadows.light
},
dark: {
palette: palette.dark,
shadows: shadows.dark,
customShadows: customShadows.dark
}
},
mixins,
components,
typography,
shape: { borderRadius: 8 },
direction: themeConfig.direction,
cssVariables: themeConfig.cssVariables,
defaultColorScheme: themeConfig.defaultMode
}
export function createTheme({ settingsState, themeOverrides }) {
const updatedCore = settingsState ? updateCoreWithSettings(baseTheme, settingsState) : baseTheme;
const updatedComponents = settingsState
? updateComponentsWithSettings(components, settingsState)
: {};
const theme = createMuiTheme(updatedCore, updatedComponents, themeOverrides);
return theme;
}
Related files:
src/App.js
orsrc/app/layout.js
src/components/settings