I would like to apply some stylesheets dynamically using Polymer. The scenario is like this:
<link rel="import" href="themes/red.styles.html" />
<link rel="import" href="themes/indigo.styles.html" />
<dom-module>
<style include="indigo-styles">
<template>
<div class="header">Header</div>
<button on-click="_toggleStylesheet"></button>
</template>
</dom-module>
<script>
Polymer({
_toggleStylesheet: function () {
// remove indigo-styles and apply red-styles and so on
}
})
</script>
Does anyone know how can this be achieved in Polymer? Thank you in advance!
Use this.updateStyles
to change the style of a Polymer.Element
.
Use Polymer.updateStyles
to apply a change globally:
Polymer.updateStyles({
'--property-one': 'var(--paper-red-900)',
'--property-two': 'var(--paper-indigo-500)',
...
'--property-whatever': 'etc'
})