Set sass variable value in Angular 7

后端 未结 6 2540
悲哀的现实
悲哀的现实 2021-02-19 22:11

I have been working with angular for the last few weeks, and now I have a requirement to dynamically style a public site. The site admin set various color codes as well as a log

6条回答
  •  执笔经年
    2021-02-19 22:30

    Since sass is a pre compiled css. we cannot dynamically change the theme without generating a seperate theme.css. This is where JSS comes to play. JSS is a javascript based style inject mechanism, where css are directly injected into the files you are using it.

    react-angular-material uses it extensively, where we can pass color variables dynamically to change theme of the application.

    for instance this guy has made it with angular.

    Docs: jss-angular, jss

    links: jss-with-angular

提交回复
热议问题