I am working on a React project with Vite as the build tool. I want to use Tailwind CSS in my project, but I’m not sure how to configure it with Vite.
I have already installed Tailwind CSS globally using npm install -g tailwindcss. However, when I try to use it in my React components, I get an error saying that the sm: class does not exist.
I have tried to install Tailwind CSS locally using npm install tailwindcss, but I’m not sure how to configure it with Vite.
The specific error is this “The sm:
class does not exist. If sm:
is a custom class, make sure it is defined within a @layer
directive.”
Can anyone guide me on how to configure Tailwind CSS with Vite in my React project? Thank you in advance!
I have tried to update the version of tailwind css in my project and I have remove and reinstall tailwind. I have added responsive variant to the tailwind.config.js file to see if “sm” class work but all in vein.
I want to use custom classes in your React app with Tailwind CSS and Vite, but you are encountering errors.
2
Answers
Make sure that you’ve added the
responsive
variants to thevariants
option in yourtailwind.config.js
file:Source: https://v2.tailwindcss.com/docs/configuring-variants
you could try installing it as a developer dependency instead try this command
then follow this link to complete configuration