Skip to content

This example demonstrates how to implement Theme Selector for the DevExtreme Project Template.

License

Notifications You must be signed in to change notification settings

DevExpress-Examples/devextreme-project-template-theme-selector

Repository files navigation

Theme Switcher for DevExtreme - How to implement Theme Selector for the DevExtreme Project Template

The DevExtreme Project Template has two default themes: base and swatch. You can change the base theme to another Material theme at runtime. To switch between themes, use the StyleSheet API. For this, disable all loaded theme stylesheet links excluding the active one.

The DevExtreme Project Template has several places where the SCSS variables used to change the color. To have the same color as main theme we use CSS variables and change them.

This sample demonstrates how to do this via a drop-down editor (SelectBox) located in a header (Toolbar). The default Project Template also has several elements that don't apply theme CSS rules (font color, background color) automatically. For these elements, you can use our predefined CSS classes:

To generate swatch themes you can use ThemeBuilder CLI:

npx devextreme-cli build-theme --base-theme="material.blue.light" --output-file="theme.additional.light" --make-swatch --assetsBasePath="../../../node_modules/devextreme/dist/css" --output-color-scheme="additional"

npx devextreme-cli build-theme --base-theme="material.blue.dark" --output-file="theme.additional.dark" --make-swatch --assetsBasePath="../../../node_modules/devextreme/dist/css" --output-color-scheme="additional"
Selector for DevExtreme - How to implement Theme Selector for the DevExtreme Project Template

Files to Review

Documentation

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)