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

Tailwind CSS v4 incompatibility caused by native cascade layers #783

Closed
timkley opened this issue Dec 1, 2024 · 1 comment
Closed

Tailwind CSS v4 incompatibility caused by native cascade layers #783

timkley opened this issue Dec 1, 2024 · 1 comment

Comments

@timkley
Copy link

timkley commented Dec 1, 2024

Tailwind CSS v4 is built on native cascade layers. This unfortunately breaks some Flux components because the injected stylesheets overwrite the utilities because unlayered declarations have a higher priority than layered declarations.

Underlying web components like ui-radio inject CSS like display: inline-block which now isn't overwritten anymore by the .flex class, resulting in a segmented radio group looking like this:

Image

Taking a look in the generated CSS reveals the problem with the new cascade, the injected styles take precedence over the utilities as they have no layer definition.

Image

Possible Solution

To solve this issue the injected styles need a layer declaration, a fix could look like this.

flux-pro/js/utils.js#6

let styles = [...]

styles = `@layer base { ${styles} }`;

I've verified this solution in Chrome by overwriting the generated script with Chrome DevTools.

Things to consider

  • Is base the most suiting layer?
  • will this have unintended consequences in other use-cases? Although everything worked in my (very basic) test: I only use the built-in components and didn't overwrite anything. From my understanding though I'd say this should still work as intendend.
@calebporzio
Copy link
Contributor

Ooof this seems like it would break many other application stylesheets. Let's see how this shakes out as Tailwind 4 releases approaches (we may not even have to address this on our end)


Going to close this and leave it as a sub issue on #811 as a psuedo "todo"

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

2 participants