Skip to content

Latest commit

 

History

History
105 lines (73 loc) · 2.89 KB

Tailwindcss.md

File metadata and controls

105 lines (73 loc) · 2.89 KB

Setting Up Tailwind CSS in a Project

Prerequisites


Steps to Set Up Tailwind CSS

1. Install Node.js

  • Download and install Node.js from the official website.
  • Verify the installation:
    node -v
    npm -v

2. Initialize a New Tailwind CSS Project

  • Open your project folder in VS Code.
  • Create the following folder structure:
    project-folder/
    ├── src/
    └── build/
    

3. Install Tailwind CSS

  • Open PowerShell or Terminal in the project folder and run:
    npm init -y
    npm install -D tailwindcss

4. Create Tailwind Configuration File

  • 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.

5. Set Up Input CSS

  • Inside the src folder, create a file named input.css and add the following code:
    @tailwind base;
    @tailwind components;
    @tailwind utilities;

6. Build Tailwind CSS Output

  • Inside the build folder, create a folder named css. 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 the build/css folder.

7. Enable Watch Mode (Optional)

  • 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

Folder Structure After Setup

project-folder/
├── src/
│   └── input.css
├── build/
│   └── css/
│       └── style.css
└── tailwind.config.js

Screenshots for Reference

Tailwind Setup Example

CSS Output Example


Notes

  • 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.