Skip to content

Embedding styles in shadow DOM #172

@seesharper

Description

@seesharper

When we pass shadow : 'open' or shadow : 'closed' we would probably expect the styles to be included in the shadow root.
Is there any way to accomplish this?

.welcome {
    color: red;
}

React component

import './Welcome.css';

export function Welcome(props: { name: string }) {
    return <div>
        <h1 className="welcome">Welcome, {props.name}!</h1>
        <slot></slot>
    </div>
}

export default Welcome;

To create the web component

const WelcomeWC = r2wc(Welcome, {
  props: {
    name: "string"
  },
  shadow: "open"
});

customElements.define("welcome-wc", WelcomeWC);

Usage

<welcome-wc>
  </welcome-wc>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions