-
Notifications
You must be signed in to change notification settings - Fork 4.5k
tailwindcss and shadow dom not working well (--spacing) #15799
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
Comments
Could you provide a reproducible example please? |
Never mind, the problem occured because of shadow doms... I was binding the stylesheet transformed by tailwindcss to a custom element, but for some reasons |
I still think that's a problem because the css variables should be available in the custom elements. I think the issue is because it's using For those who wants to investigate/pin point the issue, I made a repository with minimal example: https://github.com/vdegenne/tailwindcss-4-vite-and-shadow-doms (note: do not mind the repository name, the issue is not about |
Ok so my first intuition turned out to be correct, the problem is that @import "tailwindcss";
@layer theme {
:host {
--spacing: 0.25rem;
}
} Then it works, so |
For now I'll use the snippet above, but if one of you devs see this thread I really think that this needs to be fixed. |
There is also an issue that |
It should be noted that this is not exclusive to |
Fixes tailwindlabs#15799 This replaces the `:root` selector with `:host` in the `@theme` layer. This is necessary for the `@theme` layer to work correctly in shadow DOM. Also updates the snapshots for the tests that were affected by this change (in a separate commit)
Fixes tailwindlabs#15799 Adds a `:host` selector for the `@theme` layer. This is necessary for the `@theme` layer to work correctly in shadow DOM. Also updates the snapshots for the tests that were affected by this change.
Fixes tailwindlabs#15799 Adds a `:host` selector for the `@theme` layer. This is necessary for the `@theme` layer to work correctly in shadow DOM. Also updates the snapshots for the tests that were affected by this change.
Fixes tailwindlabs#15799 Adds a `:host` selector for the `@theme` layer. This is necessary for the `@theme` layer to work correctly in shadow DOM. Also updates the snapshots for the tests that were affected by this change.
Fixes tailwindlabs#15799 Adds a `:host` selector for the `@theme` layer. This is necessary for the `@theme` layer to work correctly in shadow DOM. Also updates the snapshots for the tests that were affected by this change.
Resolves #15799 Resolves #14478 Part-of #15005 Adds a `:host` selector for the `@theme` layer. This is necessary for the `@theme` layer to work correctly in shadow DOM. Also updates the snapshots for the tests that were affected by this change (in a separate commit). ## Test plan Tested via the Vite playground: <img width="1121" alt="Screenshot 2025-01-29 at 15 06 49" src="https://github.com/user-attachments/assets/a7908135-5ff8-472f-a053-d2c6d5c81e1b" /> Additionally made sure that `@property` defaults also work across Firefox, Chrome, and Safari (the `@property` definition from the root is pulled in) and added a UI spec. --------- Co-authored-by: Philipp Spiess <[email protected]>
What version of Tailwind CSS are you using?
For example: v4
What build tool (or framework if it abstracts the build tool) are you using?
For example: vite
What version of Node.js are you using?
For example: v23
What browser are you using?
For example: Chrome
What operating system are you using?
For example: Linux
Describe your issue
I mainly using tailwindcss to structure my layout (utilities), I've successfuly migrated from v3 to v4.
But there is a small issue, using
@import 'tailwindcss';
works but--spacing
is missing a default.which makes all properties relying on this variable broken.
The text was updated successfully, but these errors were encountered: