Tailwind CSS Setup Example
A minimal setup for using Tailwind CSS version 4 with static HTML pages, leveraging Vite for fast development and build processes. Designed as a starting template for developers to implement Tailwind with custom colors, utilities, and modern frontend tooling.
README
Tailwind CSS Setup Example
This repository provides a minimal setup for integrating Tailwind CSS version 4 into a static HTML project, utilizing Vite for development and build processes. It serves as a foundational template for developers looking to implement Tailwind CSS with custom configurations and modern tooling.
๐ Project Overview
This project demonstrates how to:
- Set up Tailwind CSS v4 with Vite.
- Customize the Tailwind configuration to include custom colors.
- Build and serve the project locally using PHP's built-in server.
๐ ๏ธ Prerequisites
Ensure you have the following installed:
๐ Project Structure
tailwindcss-setup/
โโโ dist/ # Compiled output (HTML, CSS, JS)
โโโ index.html # Main HTML page
โโโ test.html # Secondary HTML page
โโโ tailwind.config.js # Tailwind CSS configuration
โโโ tailwind.css # Custom CSS file
โโโ main.js # JavaScript entry point
โโโ package.json # Project metadata and dependencies
โ๏ธ Installation & Setup
-
Clone the repository:
git clone https://github.com/BaseMax/tailwindcss-setup.git cd tailwindcss-setup -
Install dependencies:
npm install -
Initialize Tailwind CSS:
npx tailwindcss init -p -
Configure Tailwind:
Update
tailwind.config.jsto include custom colors:/** @type {import('tailwindcss').Config} */ module.exports = { content: ['./*.html', './*.js'], theme: { extend: { colors: { 'table-header': '#091a52', 'highlight': '#ff5733', }, }, }, safelist: ['bg-table-header', 'text-highlight'], plugins: [], }; -
Create your CSS file:
In
tailwind.css, include the Tailwind directives:@tailwind base; @tailwind components; @tailwind utilities; @theme { --color-table-header: #091a52; --color-highlight: #ff5733; } -
Build the project:
npm run build -
Serve the project locally:
php -S localhost:4646 -t distVisit
http://localhost:4646in your browser to view the project.
๐ Example Pages
- index.html: The main landing page showcasing custom Tailwind styles.
- test.html: A secondary page for testing purposes.
๐ Resources
๐ License
This project is licensed under the MIT License.
Copyright 2025, Max Base
MongoDB - Build AI That Scales
