Changing CSS variables via JS in Polymer

后端 未结 3 1063
猫巷女王i
猫巷女王i 2020-12-16 02:13

In my Polymer project, I have a toolbar with a color I want to change using JavaScript. Since Polymer uses the CSS variable — paper-toolbar-background internally for styling

3条回答
  •  有刺的猬
    2020-12-16 02:43

    Basically,

    1. Grab the element
    2. Use the customStyle property to alter --paper-toolbar-background
    3. Run element.updateStyles()

    Please see the docs. [Edit] If you need an example, I've one here.

提交回复
热议问题