Re: [w3c/webcomponents] Provide a lightweight mechanism to add styles to a custom element (#468)

Why would this be blocked per the constructible stylesheet? I think it should definitely plan to incorporate such a feature, but I don't see any reason why we couldn't load in an external stylesheet to be applied or pass in a string for styles. It might not be perfect.

Also, I do think that following Angular's pattern of applying styles as an array is preferable. I can foresee some cases where a user might want to set up a single stylesheet to set up CSS variables or `@apply` rules that might be used across multiple components. It would be a big benefit to be able to define that once and reuse across multiple custom elements. Using a syntax similar to what I defined above you could do:

```javascript
class MyLibraryComponent extends HTMLElement {
  constructor() {
    super();
    this.attachShadow({
      mode: 'open',
      styles: [ 'my-library-variables', 'my-library-component' ]
    });
  }
}
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/468#issuecomment-367025968

Received on Tuesday, 20 February 2018 16:05:10 UTC