What is the process for adding tailwind CSS via npm?

Before, I was including Tailwind using a CDN. Now, I have installed it with npm and all three .css files are included, but the styles are not appearing in my HTML document.

Here is the directory structure and a link to style.css

The content of tailwind.config.js looks like this:

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

The package.json includes Tailwind CSS version 3.3.3.

All paths to the .css files for Tailwind are correct (base, components, utilities) and I can see successful requests in the network tabs.

I have checked links, paths, package.json, and tailwind.config.js files, everything appears to be in order. Why are the styles still not being applied? Note that I am using simple CSS and not SCSS/SASS.

Answer №1

To get started, follow these steps:

npm install npm install -D tailwindcss postcss autoprefixer vite

In your package.json file:

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

Your custom tailwind.config.js configuration should look like this:

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

Don't forget to link your stylesheet by adding the following line to your HTML file:

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

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Maintain the scrollable feature of the element until the final content is reached

I'm struggling to come up with the right keywords to search for my issue. I've tried using Google, but it seems my search terms are not effective. The problem I'm facing involves two relative div elements with dynamic content. This means th ...

`It is important to note that in Tailwind CSS, `h-8` does not supersede `h-4

I developed an Icon component that looks like this: import { IconProp, library } from "@fortawesome/fontawesome-svg-core"; import { far } from "@fortawesome/free-regular-svg-icons"; import { fas } from "@fortawesome/free-solid-svg- ...

npm throwing a "Permission denied" error

While using ubuntu12 on vmware without admin privileges, I encountered permission issues every time I tried to install packages like yeoman, grunt, and bower. My go-to solution for fixing these issues is detailed in this link. Everything seemed to be wor ...

An effective method to arrange divs in a line adjacent to each other

Apologies for the repetitive question, but I am in need of some answers. In my opinion: Having 1 div with a width of 100% and 2 divs inside each with a width of 50%. Why does it not fit properly? HTML: <div id="top-menu"> <div id="logo">& ...

Ways to implement CSS styling for a particular HTML element

HTML: <div class="tagline">Web Portal Name</div><br /> <div id="logged_in_user_dtls" style="color:#FFF; margin-top:15px; font:bold; width:100%; position:relative; margin-left:800px;float:left;"&g ...

What is the process by which npm consolidates the dependencies when multiple versions of the same dependency are needed?

To provide a clearer explanation of my query, I have put together a simplified version of a dependency tree: A --> <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="044644352a342a34">[email protected]</a> --> ...

Is it possible to leverage Apple Pay within the Expo app to create a unique payment token?

Is it possible to utilize Apple Pay within the Expo app to produce a payment token without having to eject and switch to React Native? I anticipated that the payment token would be generated using the React Native payment package, but unfortunately Expo G ...

Creating a Website Optimized for Mobile Devices

As a beginner web developer, I am in the process of creating a mobile-friendly website system. Currently, I am utilizing Bootstrap for responsiveness, PHP5, MySQL, and occasionally Ajax/JQuery. Recently, I came across JQuery Mobile. While I have been usin ...

Having trouble utilizing Vue CLI 3

When I tried to create a new Vue app using vue CLI 3 with the command vue create my-app, I encountered an error message saying zsh: command not found: vue. However, during the installation of vue CLI, I noticed the following warning: npm WARN deprecated ...

Unable to adjust the width of a table column within a horizontally scrollable container

I am struggling to resize the columns of a large table with 20 headers. Despite trying to place the table inside a div with overflow:auto, I still cannot achieve horizontal scrolling or make the div expand when resizing the columns. A sample code snippet ...

I am unsure about implementing the life cycle in Svelte.js

Unknown Territory I am not well-versed in front-end development. Desire to Achieve I aim to utilize the lifecycle method with SvelteJS. Error Alert An error has occurred and the lifecycle method is inaccessible: ERROR in ./node_modules/svelte/index.m ...

Is there a way for me to simultaneously run a typescript watch and start the server?

While working on my project in nodejs, I encountered an issue when trying to code and test APIs. It required running two separate consoles - one for executing typescript watch and another for running the server. Feeling frustrated by this process, I came ...

The error message encountered on Github Actions appears as follows: "bash: line 3: npm: command not

I am facing a challenge deploying a nodejs application from GitHub to a remote Ubuntu server via SSH. Below is the content of my main.yml file: name: Node Github CI on: push: branches: - master jobs: deploy: runs-on: ubuntu-latest ...

Let us know when the information on a different tab is updated

I have multiple tabs and I want to indicate when a change occurs on another tab that the user hasn't clicked. For example, if the user hits the run button while on the Data pane, I would like the Errors tab to change to red to show that there was a ch ...

Issue: The module 'xdl' cannot be located while executing the command "npm start" in React Native

Recently, I delved into learning React Native through an online Udemy course. Everything was going smoothly until a few days back when I encountered an error message after running the simple "npm start" command. Despite trying various solutions like reinst ...

Why is it that I am limited to running globally installed packages only?

Recently, I made the switch to Mac iOS and encountered an issue while setting up a new TypeScript backend project. All npm packages seem to be not functioning properly in my scripts. Cannot find module 'typescript/bin/tsc' Require stack: - /Users ...

Ways to make text within a container smoothly slide down

Hello, I have a question about jQuery as I am relatively new to it. I am currently working on creating a team members section where clicking on a team member will slide down information about that person underneath. I have managed to set up the parent co ...

The installation process for Cordova 4.0.0 is completing the setup for version 3.6

After updating to Cordova 4.0.0, I am facing an issue when running cordova platform add android. It seems to be fetching the 3.6.4 Cordova library instead of the latest version. What could be causing this? $ cordova -v 4.0.0 $ cordova platform add android ...

Troubleshooting Issue: Unable to Collapse Bootstrap Responsive Navbar Button with Custom CSS Modifications

I recently created a responsive HTML page using Bootstrap, then converted it to WordPress and made some custom CSS adjustments. In the original HTML version of the page, the navbar collapse button worked perfectly when the screen was resized. However, afte ...

Allow frontend JavaScript to retrieve a text file that is restricted to individual users

Trying to articulate my goal is challenging, but I'll do my best to clarify. My objective is to enable JavaScript (or an alternative solution) to retrieve data from a text file on a static site and utilize that data in some way. The challenge here is ...