-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
@property isn't supported in shadow roots #15005
Comments
Not 100% sure if this is related, but I noticed that in a shadow root, the defaults under Essentially rendering Tailwind unusable in shadow roots for most use cases. |
This comment was marked as spam.
This comment was marked as spam.
@blittle Thanks for the detailed writeup and sorry for the late answer here. From what I understand after doing some testing, it is indeed still required that the The snippet you have for that also changes the let atProperties = styles.slice(styles.indexOf('@property'))
let style = document.createElement('style')
style.innerText = atProperties
document.head.appendChild(style) |
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]>
I've stumbled upon this today so thanks for the workaround @blittle @philipp-spiess. I've spent an hour pulling my hair out. @philipp-spiess Does it make sense to be somehow able to configure tailwindcss to build the CSS with simple variables instead of |
Same issue, the shadow dom should follow isolation rules, we need a way not to rely on |
What version of Tailwind CSS are you using?
For example:
4.0.0-alpha.34
What build tool (or framework if it abstracts the build tool) are you using?
Web components with shadow roots.
What version of Node.js are you using?
v22.2.0
What browser are you using?
Chrome
What operating system are you using?
macOS
Reproduction URL
https://github.com/blittle/tw-shadow
Describe your issue
Tailwind v4 uses
@property
to define defaults for custom properties. At the moment, shadow roots do not support@property
. It used to be explicitly denied in the spec, but it looks like there's talk on adding it: w3c/css-houdini-drafts#1085I don't know if this is something tailwind should fix, but it took me a while to find the issue, so it's probably worth keeping this issue to document the limitation.
Here is a work-around, just attaching the
@property
definitions to the base document. It would be nice if tailwind provided an easy way to import just that content.An easy way to do that with Vite is to create a tailwind css file specifically for the properties and apply a transform:
The text was updated successfully, but these errors were encountered: