1

Previously had Tailwind included using CDN. now installed with npm, all the 3 .css files are being included but I can't see the styles being used in my html document.

Directory structure and link to style.css

tailwind.config.js is like this:

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [],
  theme: {
    extend: {},
  },
  plugins: [],
}

package.json has tailwind css 3.3.3 included

All the paths to .css files of tailwind are correct (base, components, utilities and in network tabs can see their successful requests.

I tried checking links. paths. package.json and tailwind.config.js files. everything seems in order. why are styles still not being applied? I'm using simple CSS not SCSS/SASS.

2
  • did you import the css file in your index/main js file? Commented Aug 24, 2023 at 8:27
  • yes @HarshitT i did . Commented Aug 25, 2023 at 9:48

1 Answer 1

0

You need to run this command:

npm install npm install -D tailwindcss postcss autoprefixer vite

In package.json:

scripts: {
 "start": "vite",
 "build": "vite build"
}

Your tailwind.config.js should be:

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: ["*"],
  theme: {
    extend: {},
  },
  plugins: [],
}

and Import style.css into html file like this:

<link href="./style.css" rel="stylesheet" >

Sign up to request clarification or add additional context in comments.

4 Comments

Tried this, it's not working. Same issue
Tried this, it's not working. Same issue In Network tab, this is order of requests. index.html style.css base.css components.css utilities.css ws This is in my style.css file: (all start with @) import 'node_modules/tailwindcss/base.css'; import 'node_modules/tailwindcss/components.css'; import 'node_modules/tailwindcss/utilities.css';
kindly share your code using codesandbox.
github.com/AbdullahAhmadAAK/Portfolio-Abdullah-AAK is my code. I've changed index.html file only to include tailwind by importing locally abdullahahmadaak.github.io/Portfolio-Abdullah-AAK you can view the portfolio here and see css not working

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.