-
|
What version of Tailwind CSS are you using? v4.2.2 What build tool (or framework if it abstracts the build tool) are you using? Vite 8.0.3 What version of Node.js are you using? v24.14.0 What browser are you using? Chrome What operating system are you using? macOS Reproduction URL https://github.com/balthild/twcss-repro Describe your issue Normally, the CSS layers in a project using tailwind should be
Which could be checked in the browser devtools. However, if a <style>
@reference "tailwindcss";
@layer components {
.my-class-in-style {
@apply border border-black;
}
}
</style>The CSS layers will be messed up. In my case, it becomes
This causes some styles in A workaround would be manually specifying the correct order in every <style>
@reference "tailwindcss";
@layer properties, theme, base, components, utilities;
@layer components {
.my-class-in-style {
@apply border border-black;
}
}
</style>But tailwind compiler should handle this case, maybe by adding the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Seems like the order of the stylesheets are messed up:
The import { createApp } from 'vue'
-import App from './App.vue'
-
import './main.css'
+import App from './App.vue'
createApp(App).mount('#app')Though really, as per the documentation, it is best to avoid --- a/src/App.vue
+++ b/src/App.vue
@@ -1,18 +1,8 @@
<script setup></script>
<template>
- <h1 class="my-class-in-main">You did it!</h1>
- <p class="my-class-in-style">
+ <h1 class="border border-blue-500">You did it!</h1>
+ <p class="border border-black">
Visit vuejs.org to read the documentation
</p>
</template>
-
-<style>
- @reference "tailwindcss";
-
- @layer components {
- .my-class-in-style {
- @apply border border-black;
- }
- }
-</style>
--- a/src/main.css
+++ b/src/main.css
@@ -1,7 +1 @@
@import "tailwindcss";
-
-@layer components {
- .my-class-in-main {
- @apply border border-blue-500;
- }
-}When you need components, prefer using the templating system (Vue in this case) instead of class names. |
Beta Was this translation helpful? Give feedback.

Seems like the order of the stylesheets are messed up:
The
main.cssshould be included first since it has the@layerorder there. One way to do this I've found is toimportmain.cssbeforeApp.vueinsrc/main.js:import { createApp } from 'vue' -import App from './App.vue' - import './main.css' +import App from './App.vue' createApp(App).mount('#app')Though really, as per the documentation, it is best to avoid
<style>blocks altogether: