Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Styling component #11

Closed
majordo opened this issue Nov 18, 2020 · 8 comments
Closed

Styling component #11

majordo opened this issue Nov 18, 2020 · 8 comments

Comments

@majordo
Copy link

majordo commented Nov 18, 2020

Is it possible to style component with external css file?
...Or only with inline styling?

@RathodSanjayL
Copy link

@majordo same I faced

I need an external style for the component

@VitalyBrusentsev
Copy link

If you use the Shadow DOM (default) mode, all external styles are ignored, that's the point of Shadow DOM, to isolate your component from the host styling.
The last release broke the non-Shadow DOM option (see issue #10) , and there is no fix in sight. So you can downgrade to

    "react-to-webcomponent": "^1.4.0"

and use external styling.

@majordo
Copy link
Author

majordo commented Dec 11, 2020

@VitalyBrusentsev thanks

@justinbmeyer
Copy link
Member

We have fixed this in the new release

@chriszrc
Copy link

But what about css modules? Can't these be added inside the shadowdom root?

@subramanian-iouring
Copy link

@majordo @VitalyBrusentsev
How to use external style for the component?

@VitalyBrusentsev
Copy link

@subramanian-iouring External, as in "defined in the app that includes this web component"? Then just set { shadow: false } in your registration. All external styles will affect the component's markup. (Just make sure you use the fixed version).
If you meant "located in an external .css file", then you can render a <link> tag inside your component.

@subramanian-iouring
Copy link

subramanian-iouring commented Nov 15, 2023

@subramanian-iouring External, as in "defined in the app that includes this web component"? Then just set { shadow: false } in your registration. All external styles will affect the component's markup. (Just make sure you use the fixed version). If you meant "located in an external .css file", then you can render a <link> tag inside your component.

@VitalyBrusentsev Thanks for your quick reply.
I want shadow root for my component (custom-button), so i use {shadow: "open"}.
When i use this "custom-button" component in other application, the styles are not applied.

https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_shadow_DOM#applying_styles_inside_the_shadow_dom

So, how to applying styles inside the shadow DOM in r2wc?

If i make shadow as false like you said, styles are overlapping in "custom-button" component, if same classnames are used in application and custom-button component.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants