admin管理员组文章数量:1401636
I'm using tailwindv4, when I use it on react vite, the styles are not applying.
For example I put
<h1 className = 'text-red -500'>
Hello, World </h1>
the style wouldn't apply. I followed the tailwindcss documentation but still no effect. Aside from that, IntelliSense also won't work.
I already tried applying this on my CSS file since some said on other forums that putting this will solve the problem. However, I only got some errors saying it's "unknown at rule.." ``
@tailwind base;
@tailwind components;
@tailwind utilities;
I also tried downgrading the tailwind version, but unfortunately, it's still not working.
I'm using tailwindv4, when I use it on react vite, the styles are not applying.
For example I put
<h1 className = 'text-red -500'>
Hello, World </h1>
the style wouldn't apply. I followed the tailwindcss documentation but still no effect. Aside from that, IntelliSense also won't work.
I already tried applying this on my CSS file since some said on other forums that putting this will solve the problem. However, I only got some errors saying it's "unknown at rule.." ``
@tailwind base;
@tailwind components;
@tailwind utilities;
I also tried downgrading the tailwind version, but unfortunately, it's still not working.
Share Improve this question edited Mar 24 at 0:36 Hilory 2,1417 gold badges14 silver badges30 bronze badges asked Mar 24 at 0:27 AmaranthAmaranth 1 5 |2 Answers
Reset to default 0There is an issue with your className
This is the correct way text-red-500
<h1 className="text-red-500">
Hello World
</h1>
You might also want to look up the tailwind documentation to understand how the classes work too.
In Tailwind CSS v4.0, you no longer need to import:
@tailwind base;
@tailwind components;
@tailwind utilities;
Instead, you only need a single line:
@import "tailwindcss";
And if you're a Vite user, you can now integrate Tailwind using @tailwindcss/vite instead of PostCSS.
Here’s the example in documentation:
import { defineConfig } from "vite";
import tailwindcss from "@tailwindcss/vite";
export default defineConfig({
plugins: [
tailwindcss(),
],
});
You can check the documentation for more details:
https://tailwindcss/blog/tailwindcss-v4#simplified-installation
本文标签: reactjstailwindcss v4 not applying styles on react viteStack Overflow
版权声明:本文标题:reactjs - tailwindcss v4 not applying styles on react vite - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744264692a2597892.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
@tailwind
,@plugin
,@custom-variant
,@theme
– rozsazoltan Commented Mar 24 at 5:57<h1 className = 'text-red -500'>
---><h1 className='text-red -500'>
– rozsazoltan Commented Mar 24 at 6:00