I have a best practices question about Shadow DOM styling. In all
the articles I've seen, the
:host() rule is either used to react to user states (
:hover, :focus), or, for theming, to a class. My question is about this second case. For example,
core-toolbar reacts to a
tall class and becomes taller. Add a
mini class to
paper-fab and it becomes smaller.
Is there any native element precedent for this behavior? It seems to me that in native-land attributes are used to customize elements (even when appearance is altered):
If I were a designer and I came across a class="tall" on an element and couldn't find the corresponding definition in my stylesheets, I would probably delete it. And then I would be really confused when the element's appearance changed. On the other hand, if I came across a tall attribute, I would naturally assume that the behavior/styles related to that were internal to the element. I think paper-button has this right with its raisedButton attribute.
I have heard anecdotally that CSS attribute selectors are slightly slower than class selectors, but I think that even if this is the case, implementations could easily adapt if attributes became the defacto way to customize web components.
Thoughts?