Ticket T549969
Visible to All Users

How to change themes at runtime in Angular 4

created 8 years ago

Hello,

I would like to change a theme during runtime in Angular 4.

I have included an additional theme in the cli.json:

"styles": [
"…/node_modules/font-awesome/css/font-awesome.css",
"…/node_modules/devextreme/dist/css/dx.spa.css",
"…/node_modules/devextreme/dist/css/dx.common.css",
"…/node_modules/devextreme/dist/css/dx.light.css",
"styles.css",
"generic.light.custom.css",

Works good.

But how to change the themes during runtime?

I have played with
DevExpress.ui.themes.current('dx-light');``````but could not find the imports.Thank you!

Answers approved by DevExpress Support

created 8 years ago (modified 8 years ago)

Hi,

Please perform the following steps to complete this task.

  1. Register CSS styles in the index.html file.
  2. Use the following code for export:
JavaScript
import DxThemes from 'devextreme/ui/themes';
  1. Set up a theme before our widgets are initialized as described in the dxChart title is white within dxTabPanel inside the detail row template in the Dark theme example.

Let us know your results once you have had time to try these steps.

    Show previous comments (2)
    DevExpress Support Team 8 years ago

      Hi Andre,

      I think the issue is that you are still referencing our CSS files in the angular.cli.json file in the styles section. You need to reference them on the index.html page. If this is not the case, provide me with a sample project to reproduce the issue.

        Hi Gosha,

        I have to delay the task.
        But I think I am on the right track due to your help.

        Thank you

        DevExpress Support Team 8 years ago

          No problem, Andre!

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.