Since Tailwind v4 update, all @apply directives have ceased to function.
The docs provide a workaround with @reference but the posted example is vague.
I tried this but it doesn't work:
<style lang="postcss">
// @reference './../../assets/styles/scss/main.scss'; // workaround (incorrect)
@reference "tailwindcss"; // should be sufficient
header {
@apply bg-neutral-0; // used to work in Tailwind v3
}
(...)
</style>
When I inspect the Header in the browser, it doesn't have assigned any background color.
Edit. I was missing @tailwindcss/vite but some utility classes still don't work. I.e. @apply block works, but @apply bg-neutral-0 doesn't. It throws an error:
19:26:13 [vite] (client) hmr update /src/components/Header.vue?vue&type=style&index=1&lang.postcss (x2)
Error: Cannot apply unknown utility class `bg-neutral-0`. Are you using CSS modules or similar and missing `@reference`? https://tailwindcss.com/docs/functions-and-directives#reference-directive