- VS Code: Install the Tailwind CSS IntelliSense extension to enhance the development experience with Tailwind.
- Node.js: Install Node.js from here, if not already installed.
- Download and install Node.js from the official website.
- Verify the installation:
node -v npm -v
- Open your project folder in VS Code.
- Create the following folder structure:
project-folder/ ├── src/ └── build/
- Open PowerShell or Terminal in the project folder and run:
npm init -y npm install -D tailwindcss
- In the terminal, generate a Tailwind configuration file by running:
npx tailwindcss init
- This will create a
tailwind.config.js
file in your project root. You can customize this file based on your needs.
- Inside the
src
folder, create a file namedinput.css
and add the following code:@tailwind base; @tailwind components; @tailwind utilities;
- Inside the
build
folder, create a folder namedcss
. This is where the generated Tailwind CSS output will go. - Run the following command in your terminal to generate the CSS file:
npx tailwindcss -i ./src/input.css -o ./build/css/style.css
- This will generate the
style.css
file inside thebuild/css
folder.
- If you want to automatically rebuild the CSS file every time you make changes, you can use the
--watch
option:npx tailwindcss -i ./src/input.css -o ./build/css/style.css --watch
project-folder/
├── src/
│ └── input.css
├── build/
│ └── css/
│ └── style.css
└── tailwind.config.js
- Make sure to link the generated
style.css
in your HTML file to apply the Tailwind styles. - You can customize the
tailwind.config.js
file to extend Tailwind's default configurations, add themes, or include additional plugins.
This setup allows you to efficiently use Tailwind CSS for your projects, along with live rebuilding using the --watch
mode for faster development.