Docs v1.6.0  /  Settings panel HTML5 Angular Vue.js React Laravel Laravel + Vue.js Rails Rails + Turbolinks ASP.NET Core ASP.NET Core MVC ASP.NET MVC ASP.NET MVC + Webpack Layout helpers

ThemeSettings plugin allow you to dynamically configure layout options and theme appearance.

Usage

To use ThemeSettings plugin, first of all, you need to:

  1. Include layout-helpers.js and theme-settings.js scripts in the <head> section.
  2. Initialize ThemeSettings plugin in the <script> block in the <head> section. It's important to initialize the plugin in the <head> to prevent style blinking.
  3. Add theme-settings-bootstrap-css, theme-settings-appwork-css, theme-settings-theme-css and theme-settings-colors-css classes to bootstrap, appwork, theme-* and colors stylesheets. Please note that ThemeSettings plugin initialization code must be after core stylesheets.
<!-- Core stylesheets -->
<link rel="stylesheet" href="path/to/css/bootstrap.css" class="theme-settings-bootstrap-css">
<link rel="stylesheet" href="assets/vendor/css/appwork.css" class="theme-settings-appwork-css">
<link rel="stylesheet" href="path/to/theme-css/theme-corporate.css" class="theme-settings-theme-css">
<link rel="stylesheet" href="path/to/css/colors.css" class="theme-settings-colors-css">
<link rel="stylesheet" href="path/to/css/uikit.css">

    <!-- Layout helpers -->
<script src="path/to/layout-helpers.js"></script>

<!-- Theme settings -->
<script src="path/to/theme-settings.js"></script>
<script>
  window.themeSettings = new ThemeSettings({
    cssPath: 'path/to/css/',
    themesPath: 'path/to/theme-css/'
  });
</script>
// Get current settings. Do not change it directly, use methods instead.
console.log(window.themeSettings.settings);

/*
{
  "cssPath": "path/to/css/",
  "themesPath": "path/to/theme-css/",
  "cssFilenamePattern": "%name%.css",
  "navbarBgs": [ ... ],
  "defaultNavbarBg": "navbar-theme",
  "sidenavBgs": [ ... ],
  "defaultSidenavBg": "sidenav-theme",
  "footerBgs": [ ... ],
  "defaultFooterBg": "footer-theme",
  "availableThemes": [ ... ],
  "defaultTheme": { ... },
  "styles": [ ... ],
  "lang": "en",
  "controls": [ ... ],
  "rtl": false,
  "material": false,
  "layoutPosition": "static",
  "layoutReversed": false,
  "layoutNavbarFixed": false,
  "layoutFooterFixed": false,
  "navbarBg": "navbar-theme",
  "sidenavBg": "sidenav-theme",
  "footerBg": "footer-theme",
  "theme": { ... }
}
*/

Globals

You can configure ThemeSettings application-wide by modifying global variables.

ThemeSettings.AVAILABLE_THEMES.push({
  name: 'theme-name',
  title: 'Theme title',
  colors: {
    primary: '#333',
    navbar: '#666',
    sidenav: '#999'
  },
  // Colors for dark style
  colorsDark: {
    primary: '#eee',
    navbar: '#ccc',
    sidenav: '#aaa'
  }
});

window.themeSettings = new ThemeSettings({
  defaultTheme: 'theme-name',
  ...
});
Variable Value
ThemeSettings.AVAILABLE_THEMES
[
  { name: 'theme-air', title: 'Air', colors: { primary: '#3c97fe', navbar: '#f8f8f8', sidenav: '#f8f8f8' }, colorsDark: { primary: '#3c97fe', navbar: '#25282e', sidenav: '#25282e' } },
  { name: 'theme-corporate', title: 'Corporate', colors: { primary: '#26B4FF', navbar: '#fff', sidenav: '#2e323a' }, colorsDark: { primary: '#26B4FF', navbar: '#1c1f24', sidenav: '#2f3238' } },
  { name: 'theme-cotton', title: 'Сotton', colors: { primary: '#e84c64', navbar: '#ffffff', sidenav: '#ffffff' }, colorsDark: { primary: '#e84c64', navbar: '#25282e', sidenav: '#d2d3d4' } },
  { name: 'theme-gradient', title: 'Gradient', colors: { primary: '#775cdc', navbar: '#ffffff', sidenav: 'linear-gradient(to top, #4e54c8, #8c55e4)' }, colorsDark: { primary: '#775cdc', navbar: '#1c1f24', sidenav: 'linear-gradient(to top, #4e54c8, #8c55e4)' } },
  { name: 'theme-paper', title: 'Paper', colors: { primary: '#17b3a3', navbar: '#ffffff', sidenav: '#ffffff' }, colorsDark: { primary: '#17b3a3', navbar: '#32353b', sidenav: '#ffffff' } },
  { name: 'theme-shadow', title: 'Shadow', colors: { primary: '#7b83ff', navbar: '#f8f8f8', sidenav: '#ececf9' }, colorsDark: { primary: '#7b83ff', navbar: '#25282e', sidenav: '#424256' } },
  { name: 'theme-soft', title: 'Soft', colors: { primary: '#1cbb84', navbar: '#39517b', sidenav: '#ffffff' }, colorsDark: { primary: '#1cbb84', navbar: '#39517b', sidenav: '#E9E9EA' } },
  { name: 'theme-sunrise', title: 'Sunrise', colors: { primary: '#fc5a5c', navbar: '#222222', sidenav: '#ffffff' }, colorsDark: { primary: '#fc5a5c', navbar: '#fff', sidenav: '#1c1f24' } },
  { name: 'theme-twitlight', title: 'Twitlight', colors: { primary: '#4c84ff', navbar: '#343c44', sidenav: '#3f4853' }, colorsDark: { primary: '#4c84ff', navbar: '#2b3239', sidenav: '#303942' } },
  { name: 'theme-vibrant', title: 'Vibrant', colors: { primary: '#fc5a5c', navbar: '#f8f8f8', sidenav: '#222222' }, colorsDark: { primary: '#fc5a5c', navbar: '#25282e', sidenav: '#1c1f24' } },
]
ThemeSettings.NAVBAR_BGS
[
  'navbar-theme',
  'primary',
  'primary-dark navbar-dark',
  'primary-darker navbar-dark',
  'secondary',
  'secondary-dark navbar-dark',
  'secondary-darker navbar-dark',
  'success',
  'success-dark navbar-dark',
  'success-darker navbar-dark',
  'info',
  'info-dark navbar-dark',
  'info-darker navbar-dark',
  'warning',
  'warning-dark navbar-light',
  'warning-darker navbar-light',
  'danger',
  'danger-dark navbar-dark',
  'danger-darker navbar-dark',
  'dark',
  'white',
  'light',
  'lighter'
]
ThemeSettings.SIDENAV_BGS
[
  'sidenav-theme',
  'primary',
  'primary-dark sidenav-dark',
  'primary-darker sidenav-dark',
  'secondary',
  'secondary-dark sidenav-dark',
  'secondary-darker sidenav-dark',
  'success',
  'success-dark sidenav-dark',
  'success-darker sidenav-dark',
  'info',
  'info-dark sidenav-dark',
  'info-darker sidenav-dark',
  'warning',
  'warning-dark sidenav-light',
  'warning-darker sidenav-light',
  'danger',
  'danger-dark sidenav-dark',
  'danger-darker sidenav-dark',
  'dark',
  'white',
  'light',
  'lighter'
]
ThemeSettings.FOOTER_BGS
[
  'footer-theme',
  'primary',
  'primary-dark footer-dark',
  'primary-darker footer-dark',
  'secondary',
  'secondary-dark footer-dark',
  'secondary-darker footer-dark',
  'success',
  'success-dark footer-dark',
  'success-darker footer-dark',
  'info',
  'info-dark footer-dark',
  'info-darker footer-dark',
  'warning',
  'warning-dark footer-light',
  'warning-darker footer-light',
  'danger',
  'danger-dark footer-dark',
  'danger-darker footer-dark',
  'dark',
  'white',
  'light',
  'lighter'
]
ThemeSettings.LANGUAGES
{
  en: {
    panel_header: 'SETTINGS',
    rtl_switcher: 'RTL direction',
    style_switcher_default: 'Light style',
    style_switcher_material: 'Material style',
    style_switcher_dark: 'Dark style',
    layout_header: 'LAYOUT',
    layout_static: 'Static',
    layout_offcanvas: 'Offcanvas',
    layout_fixed: 'Fixed',
    layout_fixed_offcanvas: 'Fixed offcanvas',
    layout_navbar_swicher: 'Fixed navbar',
    layout_footer_swicher: 'Fixed footer',
    layout_reversed_swicher: 'Reversed',
    navbar_bg_header: 'NAVBAR BACKGROUND',
    sidenav_bg_header: 'SIDENAV BACKGROUND',
    footer_bg_header: 'FOOTER BACKGROUND',
    theme_header: 'THEME'
  }
}

Internationalization

You can add translations by inserting a translation object into the ThemeSettings.LANGUAGES. Optionally, you can translate theme titles. Full example:

ThemeSettings.LANGUAGES.en = {
  panel_header: 'SETTINGS',
  rtl_switcher: 'RTL direction',
  style_switcher_default: 'Light style',
  style_switcher_material: 'Material style',
  style_switcher_dark: 'Dark style',
  layout_header: 'LAYOUT',
  layout_static: 'Static',
  layout_offcanvas: 'Offcanvas',
  layout_fixed: 'Fixed',
  layout_fixed_offcanvas: 'Fixed offcanvas',
  layout_navbar_swicher: 'Fixed navbar',
  layout_footer_swicher: 'Fixed footer',
  layout_reversed_swicher: 'Reversed',
  navbar_bg_header: 'NAVBAR BACKGROUND',
  sidenav_bg_header: 'SIDENAV BACKGROUND',
  footer_bg_header: 'FOOTER BACKGROUND',
  theme_header: 'THEME',
  themes: { // "themes" key is optional. You can translate theme titles partially
    'theme-air': 'Air',
    'theme-corporate': 'Corporate',
    'theme-cotton': 'Сotton',
    'theme-gradient': 'Gradient',
    'theme-paper': 'Paper',
    'theme-shadow': 'Shadow',
    'theme-soft': 'Soft',
    'theme-sunrise': 'Sunrise',
    'theme-twitlight': 'Twitlight',
    'theme-vibrant': 'Vibrant'
  }
};

ThemeSettings.LANGUAGES.fr = { ... };
ThemeSettings.LANGUAGES.de = { ... };

// Then initialize the plugin with the required language:
window.themeSettings = new ThemeSettings({
  lang: 'fr',
  ...
});

// Or change the language at runtime:
window.themeSettings.setLang('de');

Options

Option Description
cssPath Core stylesheets path. Must ends with a slash. Required
themesPath Theme stylesheets path. Must ends with a slash. Required
cssFilenamePattern

Filename pattern.

Default: %name%.css

For example, if you set this option to %name%.minified.css, the plugin will load the next paths:

  • path/to/css/bootstrap.minified.css
  • path/to/css/bootstrap-material.minified.css
  • path/to/css/bootstrap-dark.minified.css
  • path/to/css/appwork.minified.css
  • path/to/css/appwork-material.minified.css
  • path/to/css/appwork-dark.minified.css
  • path/to/css/colors.minified.css
  • path/to/css/colors-material.minified.css
  • path/to/css/colors-dark.minified.css
  • path/to/theme-css/theme-corporate.minified.css
  • ...
controls

Using this option you can disable ThemeSettings controls. Just pass an array of the required controls.

Default: ['rtl', 'style', 'layoutPosition', 'layoutNavbarFixed', 'layoutFooterFixed', 'layoutReversed', 'navbarBg', 'sidenavBg', 'footerBg', 'themes']

For example, if you set this option to ['rtl', 'style'], ThemeSettings panel will contain only RTL and style switchers.
styles

This option allows to set styles that will be available for choosing. Pass an array of the required styles.

Default: ['light', 'material', 'dark']

sidenavBgs

Available layout sidenav backgrounds.

Default: ['sidenav-theme', 'primary', 'primary-dark sidenav-dark', 'primary-darker sidenav-dark', 'secondary', 'secondary-dark sidenav-dark', 'secondary-darker sidenav-dark', 'success', 'success-dark sidenav-dark', 'success-darker sidenav-dark', 'info', 'info-dark sidenav-dark', 'info-darker sidenav-dark', 'warning', 'warning-dark sidenav-light', 'warning-darker sidenav-light', 'danger', 'danger-dark sidenav-dark', 'danger-darker sidenav-dark', 'dark', 'white', 'light', 'lighter']
defaultSidenavBg

Default layout sidenav background. The plugin uses this value if no sidenav background value found in the localStorage or its value is incorrect.

Default: sidenav-theme
navbarBgs

Available layout navbar backgrounds.

Default: ['navbar-theme', 'primary', 'primary-dark navbar-dark', 'primary-darker navbar-dark', 'secondary', 'secondary-dark navbar-dark', 'secondary-darker navbar-dark', 'success', 'success-dark navbar-dark', 'success-darker navbar-dark', 'info', 'info-dark navbar-dark', 'info-darker navbar-dark', 'warning', 'warning-dark navbar-light', 'warning-darker navbar-light', 'danger', 'danger-dark navbar-dark', 'danger-darker navbar-dark', 'dark', 'white', 'light', 'lighter']
defaultNavbarBg

Default layout navbar background. The plugin uses this value if no navbar background value found in the localStorage or its value is incorrect.

Default: navbar-theme
footerBgs

Available layout footer backgrounds.

Default: ['footer-theme', 'primary', 'primary-dark footer-dark', 'primary-darker footer-dark', 'secondary', 'secondary-dark footer-dark', 'secondary-darker footer-dark', 'success', 'success-dark footer-dark', 'success-darker footer-dark', 'info', 'info-dark footer-dark', 'info-darker footer-dark', 'warning', 'warning-dark footer-light', 'warning-darker footer-light', 'danger', 'danger-dark footer-dark', 'danger-darker footer-dark', 'dark', 'white', 'light', 'lighter']
defaultFooterBg

Default layout footer background. The plugin uses this value if no footer background value found in the localStorage or its value is incorrect.

Default: footer-theme
availableThemes

Available themes. Theme item has the next structure:

{
  name: '{theme_filename_without_extension}',
  title: '{theme_name}',
  colors: {
    primary: '{primary_color}',
    navbar: '{bg_navbar_theme}',
    sidenav: '{bg_sidenav_theme}'
  },
  colorsDark: {
    primary: '{dark_primary_color}',
    navbar: '{dark_bg_navbar_theme}',
    sidenav: '{dark_bg_sidenav_theme}'
  }
}

Default:

[
  { name: 'theme-air', title: 'Air', colors: { primary: '#3c97fe', navbar: '#f8f8f8', sidenav: '#f8f8f8' }, colorsDark: { primary: '#3c97fe', navbar: '#25282e', sidenav: '#25282e' } },
  { name: 'theme-corporate', title: 'Corporate', colors: { primary: '#26B4FF', navbar: '#fff', sidenav: '#2e323a' }, colorsDark: { primary: '#26B4FF', navbar: '#1c1f24', sidenav: '#2f3238' } },
  { name: 'theme-cotton', title: 'Сotton', colors: { primary: '#e84c64', navbar: '#ffffff', sidenav: '#ffffff' }, colorsDark: { primary: '#e84c64', navbar: '#25282e', sidenav: '#d2d3d4' } },
  { name: 'theme-gradient', title: 'Gradient', colors: { primary: '#775cdc', navbar: '#ffffff', sidenav: 'linear-gradient(to top, #4e54c8, #8c55e4)' }, colorsDark: { primary: '#775cdc', navbar: '#1c1f24', sidenav: 'linear-gradient(to top, #4e54c8, #8c55e4)' } },
  { name: 'theme-paper', title: 'Paper', colors: { primary: '#17b3a3', navbar: '#ffffff', sidenav: '#ffffff' }, colorsDark: { primary: '#17b3a3', navbar: '#32353b', sidenav: '#ffffff' } },
  { name: 'theme-shadow', title: 'Shadow', colors: { primary: '#7b83ff', navbar: '#f8f8f8', sidenav: '#ececf9' }, colorsDark: { primary: '#7b83ff', navbar: '#25282e', sidenav: '#424256' } },
  { name: 'theme-soft', title: 'Soft', colors: { primary: '#1cbb84', navbar: '#39517b', sidenav: '#ffffff' }, colorsDark: { primary: '#1cbb84', navbar: '#39517b', sidenav: '#E9E9EA' } },
  { name: 'theme-sunrise', title: 'Sunrise', colors: { primary: '#fc5a5c', navbar: '#222222', sidenav: '#ffffff' }, colorsDark: { primary: '#fc5a5c', navbar: '#fff', sidenav: '#1c1f24' } },
  { name: 'theme-twitlight', title: 'Twitlight', colors: { primary: '#4c84ff', navbar: '#343c44', sidenav: '#3f4853' }, colorsDark: { primary: '#4c84ff', navbar: '#2b3239', sidenav: '#303942' } },
  { name: 'theme-vibrant', title: 'Vibrant', colors: { primary: '#fc5a5c', navbar: '#f8f8f8', sidenav: '#222222' }, colorsDark: { primary: '#fc5a5c', navbar: '#25282e', sidenav: '#1c1f24' } },
]
defaultTheme

Default theme index or name. Accepts number or string. The plugin uses this value if no theme value found in the localStorage or its value is incorrect.

Default: 1
lang

Current language. The value must be in the ThemeSettings.LANGUAGES, otherwise an error will be thrown.

Default: en
pathResolver

A callback function that lets you change the stylesheet url on the fly. Accepts stylesheet url. Must return stylesheet url.

This function is useful when you're using hashes in filenames - just load the manifest and return the correct path.

Example:

window.themeSettings = new ThemeSettings({
  cssPath: 'css/',
  themesPath: 'theme-css/'
  cssFilenamePattern: '%name%',
  pathResolver: function(path) {
    var pathMap = {
      'css/bootstrap': 'css/bootstrap_some-hash-1',
      'css/bootstrap-material': 'css/bootstrap-material_some-hash-2',
      'css/bootstrap-dark': 'css/bootstrap-dark_some-hash-3',
      'css/appwork': 'css/appwork_some-hash-4',
      'css/appwork-material': 'css/appwork-material_some-hash-5',
      'css/appwork-dark': 'css/appwork-dark_some-hash-6',
      'css/colors': 'css/colors_some-hash-7',
      'css/colors-material': 'css/colors-material_some-hash-8',
      'css/colors-dark': 'css/colors-dark_some-hash-9',

      'theme-css/theme-air': 'css/theme-air_some-hash-10',
      'theme-css/theme-air-material': 'css/theme-air-material_some-hash-11',
      'theme-css/theme-air-dark': 'css/theme-air-dark_some-hash-12',
      ...
    };

    return 'http://example.com/assets/' + (pathMap[path] || path) + '.css';
  },
  ...
});
onSettingsChange

A callback function which invoked after settings changed and stored in the localStorage. Accepts ThemeSettings.settings object.

Example:

window.themeSettings = new ThemeSettings({
  ...

  onSettingsChange: function(currentSettings) {
    ...
  },

  ...
});

Methods

Method Description
setRtl(rtl) Set to true to enable RTL direction, false to disable. Will reload page.
setStyle(style) Set the current style. Accepts the next values:
  • 'light'
  • 'material'
  • 'dark'
setTheme(themeName, updateStorage = true, cb = null) Set the current theme by name, must be in the settings.availableThemes array. The cb function will be invoked after the theme is loaded. Set updateStorage to false to not update localStorage.
isLightStyle() Returns true if the current style is light, otherwise returns false.
isMaterialStyle() Returns true if the current style is material, otherwise returns false.
isDarkStyle() Returns true if the current style is dark, otherwise returns false.
setLayoutPosition(pos, updateStorage = true)

Set layout position. Available values:

  • static
  • static-offcanvas
  • fixed
  • fixed-offcanvas

Set updateStorage to false to not update localStorage.
setLayoutNavbarFixed(fixed, updateStorage = true) Set to true to make the layout navbar fixed, false to make it static. Set updateStorage to false to not update localStorage.
setLayoutFooterFixed(fixed, updateStorage = true) Set to true to make the layout footer fixed, false to make it static. Set updateStorage to false to not update localStorage.
setLayoutReversed(reversed, updateStorage = true) Set to true to make the layout reversed, false to reset. Set updateStorage to false to not update localStorage.
setNavbarBg(bg, updateStorage = true) Set the layout navbar background. The value must be in the settings.navbarBgs array. Set updateStorage to false to not update localStorage.
setSidenavBg(bg, updateStorage = true) Set the layout sidenav background. The value must be in the settings.sidenavBgs array. Set updateStorage to false to not update localStorage.
setFooterBg(bg, updateStorage = true) Set the layout footer background. The value must be in the settings.footerBgs array. Set updateStorage to false to not update localStorage.
setLang(language) Set language. The value must be in the ThemeSettings.LANGUAGES, otherwise an error will be thrown.
update() Update settings panel.
updateNavbarBg() Update the layout navbar background.
updateSidenavBg() Update the layout sidenav background.
updateFooterBg() Update the layout footer background.
clearLocalStorage() Clear localStorage values.
destroy() Destroy ThemeSettings instance.

Configuration generator

Use ThemeSettings configuration generator to simplify the initial setup.