Replies: 7 comments 24 replies
-
Hey! The example you gave will already work, Tailwind reserves the https://tailwindcss.com/docs/adding-custom-styles#using-css-and-layer Your |
Beta Was this translation helpful? Give feedback.
-
Now that CSS |
Beta Was this translation helpful? Give feedback.
-
Can you give me a real example of code that won’t work properly? I’m struggling to think of a situation that presents a real problem because you have complete control over where Preflight is inserted, and you can add any custom layers you want either before or after it. The whole reason Tailwind generates its code into three distinct layers is to give you this control. |
Beta Was this translation helpful? Give feedback.
-
Even if it's possible to deal with the override problem (see @wongjn's solution above), it's not clear to me how I can use Tailwind's Won't the Tailwind processor simply assume that |
Beta Was this translation helpful? Give feedback.
-
It seems like the solution mentioned above will trigger the |
Beta Was this translation helpful? Give feedback.
-
I'm still getting that nesting error, but things seem to be working as expected. Thanks for that article, @o-t-w! |
Beta Was this translation helpful? Give feedback.
-
I think it's best if Tailwind doesn't polyfill the @adamwathan here is a real example of code that won't work: Currently it is not possible to dynamically import multiple css files (for code splitting for example) and use the layer functionality to create the right CSS layering. <head>
<!-- (includes base styles and tailwind) -->
<link rel="stylesheet" href="main.css">
<!-- these files can't use cascading layer functionality to get onto the right layer -->
<link rel="stylesheet" href="dashboard-bundle.css"> <!-- (optionally rendered based on route) -->
<link rel="stylesheet" href="other-large-module.css"> <!-- (optionally rendered based on route) -->
</head> I like the polyfill TailwindCSS currently uses through PostCSS but it should also work together with the default https://css-tricks.com/css-cascade-layers/#aa-using-design-systems-and-component-libraries What do you think of this situation? It is mostly caused because in our projects we use CSS together with utility classes of TailwindCSS so we do depend on large CSS modules for specific pages. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Cascade layers are available since Chrome 99 and Firefox 97. As of March 8th it will be in Safari stable.
Cascade layers will be useful for Tailwind users because it will make it less necessary for users to set
important: true,
in their config as layers provide a nicer way to make sure utility classes always win.However, for people that want the override styles provided by Tailwind, there will be a problem.
A lot of people won't rely 100% on the Tailwind way of doing things, and will instead also want to write some of their own CSS. If I want to write any of my only styles inside a layer, these will be overridden by the Tailwind reset.
e.g.
will be overridden by
button {background-color: transparent; }
from the Tailwind stylesheet. (Styles outside a layer will always win out over styles defined in a layer, regardless of specificity or source order.)I think layers are a useful addition to CSS that will quickly gain widespread adoption. It would be awesome if Tailwind had a nice way of dealing with layers as soon as they gain cross-browser support.
Beta Was this translation helpful? Give feedback.
All reactions