Settings

This section will describe how you settings your theme.


Change default settings

Remove local storage or cookies when you change settings.

<SettingsProvider
  defaultSettings={{
    colorScheme: 'light',
    direction: 'ltr',
    contrast: 'default',
    navLayout: 'vertical',
    primaryColor: 'default',
    navColor: 'integrate',
    compactLayout: true,
    fontFamily: defaultFont,
  }}
/>
src/App.js, src/app/layout.js

Base theme

Without settings and locales.

export function createTheme() {
  const initialTheme = {
    colorSchemes,
    shadows: shadows('light'),
    customShadows: customShadows('light'),
    shape: { borderRadius: 8 },
    components,
    typography,
    cssVarPrefix: '',
    shouldSkipGeneratingVar,
  };
 
  const theme = extendTheme(initialTheme, overridesTheme);
 
  return theme;
}
src/theme/create-theme.ts

With localization
export function createTheme(
  localeComponents,
) {
  const initialTheme = {
    colorSchemes,
    shadows: shadows('light'),
    customShadows: customShadows('light'),
    shape: { borderRadius: 8 },
    components,
    typography,
    cssVarPrefix: '',
    shouldSkipGeneratingVar,
  };
 
  const theme = extendTheme(
    initialTheme,
    localeComponents,
  );
 
  return theme;
}
src/theme/create-theme.ts

With settings
export function createTheme(
  settings
) {
  const initialTheme = {
    colorSchemes,
    shadows: shadows(settings.colorScheme),
    customShadows: customShadows(settings.colorScheme),
    direction: settings.direction,
    shape: { borderRadius: 8 },
    components,
    typography,
    cssVarPrefix: '',
    shouldSkipGeneratingVar,
  };
 
  const updateTheme = updateCoreWithSettings(initialTheme, settings);
 
  const theme = extendTheme(
    updateTheme,
    updateComponentsWithSettings(settings),
  );
 
  return theme;
}
src/theme/create-theme.ts

  • src/App.js or src/app/layout.js
  • src/components/settings