Do you have any ideas why @layer
in Tailwind CSS doesn't work?
If I write in my styles.css for example
h1 {
@apply text-2xl;
}
it works but if I do:
@layer base {
h1 {
@apply text-2xl;
}
}
it doesn't. It just doesn't see this style.
It's possible that your
h1
style is getting purged by Tailwind's styler purging process: https://tailwindcss.com/docs/controlling-file-size:Since, presumably, you're not referencing the
h1
style with@apply
, maybe Tailwind is considering the style unused. Although, one would hope that Tailwind would not purge a tag-based selector.Take a look at the CSS file that is built, either on the file system or inspector in the browser, and look for your
h1
styles.From the Tailwind docs, maybe try adding
h1
to your whitelist - although I don't think it will work since the whitelist seems to want class-based selectors.I recommend asking if tag selectors work with layers on the Tailwind Discord or forum: https://tailwindcss.com/community