Proof of concept / strategy decision: Complete isolation / Shadow DOM everywhere vs slots. #57
Replies: 3 comments
-
|
Beta Was this translation helpful? Give feedback.
-
I remember reading that you could override styles in shadow DOM elements if you really wanted, but I can't find this article any more. There used to be a way (as linked above), so maybe the article was out of date or I misunderstood. If we want to prevent the text-based cascading styles, we can reset them in the web component styles. Example https://developers.google.com/web/fundamentals/web-components/shadowdom#reset. If we want to allow partial overriding, I think the |
Beta Was this translation helpful? Give feedback.
-
On an internal project, we have been using slots for content and properties / attributes for configuration when we can. This has worked pretty well. When we have issues with styling in a single component, such as facts in an infographic, we make a separate component.
This is a little work, but it's honestly not that much and the components themselves are pretty simple. We've used this pattern for mostly menus, pager, slides, and infographic. In Storybook, we put them in a The exception so far to this rule is form elements like checkboxes that we have parsed and re-created in the shadow DOM. Otherwise we try to leave the light DOM alone. Somewhat related, I've tried to stop using the default slot whenever possible. It is vague and we typically end up with multiple slots. Knowing which |
Beta Was this translation helpful? Give feedback.
-
Do we want our web components to have no styles coming from outside them?
Web components already isolate styles from going from the web component to the light DOM.
The various parts of the web components do not fully isolate styles from coming from the light DOM.
Notes
Some posible solutions:
Some challenges with those solutions:
Beta Was this translation helpful? Give feedback.
All reactions