Replies: 5 comments 2 replies
-
Hello, To add compatibility for the Shadow DOM, you can modify the Tailwind configuration to include :host in addition to :root. Here's how you can approach it: Customizing the Tailwind Configuration: In your tailwind.config.js file, you can extend Tailwind's CSS variables to be included in both :root and :host. You might need to write a custom PostCSS plugin or use Tailwind's @layer to ensure this gets applied. Using PostCSS with Tailwind (or Tailwind Plugin): You can customize the @theme layer to prepend :root, :host like this: js Ensure Tailwind's CSS is Applied in Shadow DOM: When you generate your Web Component, ensure that the generated CSS is encapsulated within the component's shadow root. Here's a basic example: jsx class MyComponent extends HTMLElement { customElements.define('my-component', MyComponent); |
Beta Was this translation helpful? Give feedback.
-
There was a similar question asked in the Discord server with a maintainer response as follows:
|
Beta Was this translation helpful? Give feedback.
-
I was testing v4 inside shadow dom, and I faced this issue with |
Beta Was this translation helpful? Give feedback.
-
I actually have the exact opposite issue as it looks like it is applying to This issue with this is now any properties defined in the upper scope get overwritten which means nothing propagates to the shadowdom children.
The work around is to set the
Did this get changed so it applies on :host as well? |
Beta Was this translation helpful? Give feedback.
-
I'm chiming in here, too, with the request to be able to disable outputting I'm using tailwindcss to style pdf documents that are generated by WeasyPrint. It worked fine with v3 and I mostly got it to work with v4, too: I could disable some Tailwindcss outputs selectors like I know that tailwindcss doesn't target such document generators, but maybe it makes sense to reduce the css anyways when one is sure there is never any shadow DOM used and a tailwindcss config option could be provided to do so? Maybe it is possible already and I just don't know how? |
Beta Was this translation helpful? Give feedback.
-
Hello,
I'm using Tailwind v4 with Vite on a project where I want to create Web Component using React and Tailwind for the styles.
I noticed that all the CSS Variables included on the @theme layer are inside a ":root" selector, as is mentioned on the Tailwind v4.0 Beta Documentation:
I would be great if all the theme variables are included using ":root, :host" selector for Shadow DOM compatibility. Example:
You can check why on this article:
https://techblog.skeepers.io/create-a-web-component-from-a-react-component-bbe7c5f85ee6
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions