lit-element icon indicating copy to clipboard operation
lit-element copied to clipboard

Theming solution for LitElement

Open nicolejadeyee opened this issue 4 years ago • 2 comments

nicolejadeyee avatar Feb 27 '20 17:02 nicolejadeyee

hello!

i just wanted to share that in my case, i found applying a shared css theme to many shadow-dom lit-element components was no sweat

using a decorator called mixin-css, and a couple helper functions, theme-components and register-components, i can easily share a css theme across many components like this:

registerComponents(themeComponents(theme, components))
 //  ↑              ↑
 //  │              └——— apply the css theme to components
 //  │
 //  └—————————————————— register components via customElements.define

this pattern decouples each component from any particular theme, making themes for components easily swappable at a high level

  :wave: chase

chase-moskal avatar Mar 01 '20 03:03 chase-moskal

IIUC, it basically achieves that using Constructible Stylesheets with fallback when needed.

motss avatar Mar 16 '20 06:03 motss

Closing in favor of lit/rfcs#10

sorvell avatar Sep 08 '22 20:09 sorvell