Skip to content
Discussion options

You must be logged in to vote

Yes, both are supported. Every component renders light DOM by default, and you opt a specific component into shadow DOM with one static field:

class Card extends WebComponent({ title: String }) {
  static shadow = true;      // this component now renders shadow DOM
  static styles = css`
    :host { display: block; }
    .body { padding: 1rem; }
  `;
  render() {
    return html`<div class="body"><h3>${this.title}</h3><slot></slot></div>`;
  }
}
Card.register('my-card');

Drop the static shadow = true line (or set it to false) and the same component renders light DOM instead. That is the whole switch, it is per component, and works either way.

Which one to reach for:

  • Light DOM (the defaul…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by mladaniOracle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants