|
1 | | -# tailwindcss-setup |
| 1 | +# Tailwind CSS Setup Example |
| 2 | + |
| 3 | +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. |
| 4 | + |
| 5 | +## 🚀 Project Overview |
| 6 | + |
| 7 | +This project demonstrates how to: |
| 8 | + |
| 9 | +* Set up Tailwind CSS v4 with Vite. |
| 10 | +* Customize the Tailwind configuration to include custom colors. |
| 11 | +* Build and serve the project locally using PHP's built-in server. |
| 12 | + |
| 13 | +## 🛠️ Prerequisites |
| 14 | + |
| 15 | +Ensure you have the following installed: |
| 16 | + |
| 17 | +* [Node.js](https://nodejs.org/) (v16 or higher recommended) |
| 18 | +* [npm](https://npmjs.com/) |
| 19 | +* [PHP](https://www.php.net/) (for local server) |
| 20 | + |
| 21 | +## 📁 Project Structure |
| 22 | + |
| 23 | +``` |
| 24 | +tailwindcss-setup/ |
| 25 | +├── dist/ # Compiled output (HTML, CSS, JS) |
| 26 | +├── index.html # Main HTML page |
| 27 | +├── test.html # Secondary HTML page |
| 28 | +├── tailwind.config.js # Tailwind CSS configuration |
| 29 | +├── tailwind.css # Custom CSS file |
| 30 | +├── main.js # JavaScript entry point |
| 31 | +└── package.json # Project metadata and dependencies |
| 32 | +``` |
| 33 | + |
| 34 | +## ⚙️ Installation & Setup |
| 35 | + |
| 36 | +1. **Clone the repository:** |
| 37 | + |
| 38 | + ```bash |
| 39 | + git clone https://github.com/BaseMax/tailwindcss-setup.git |
| 40 | + cd tailwindcss-setup |
| 41 | + ``` |
| 42 | + |
| 43 | +2. **Install dependencies:** |
| 44 | + |
| 45 | + ```bash |
| 46 | + npm install |
| 47 | + ``` |
| 48 | + |
| 49 | +3. **Initialize Tailwind CSS:** |
| 50 | + |
| 51 | + ```bash |
| 52 | + npx tailwindcss init -p |
| 53 | + ``` |
| 54 | + |
| 55 | +4. **Configure Tailwind:** |
| 56 | + |
| 57 | + Update `tailwind.config.js` to include custom colors: |
| 58 | + |
| 59 | + ```javascript |
| 60 | + /** @type {import('tailwindcss').Config} */ |
| 61 | + module.exports = { |
| 62 | + content: ['./*.html', './*.js'], |
| 63 | + theme: { |
| 64 | + extend: { |
| 65 | + colors: { |
| 66 | + 'table-header': '#091a52', |
| 67 | + 'highlight': '#ff5733', |
| 68 | + }, |
| 69 | + }, |
| 70 | + }, |
| 71 | + safelist: ['bg-table-header', 'text-highlight'], |
| 72 | + plugins: [], |
| 73 | + }; |
| 74 | + ``` |
| 75 | + |
| 76 | +5. **Create your CSS file:** |
| 77 | + |
| 78 | + In `tailwind.css`, include the Tailwind directives: |
| 79 | + |
| 80 | + ```css |
| 81 | + @tailwind base; |
| 82 | + @tailwind components; |
| 83 | + @tailwind utilities; |
| 84 | + |
| 85 | + @layer utilities { |
| 86 | + .bg-table-header { |
| 87 | + background-color: #091a52; |
| 88 | + } |
| 89 | + .text-highlight { |
| 90 | + color: #ff5733; |
| 91 | + } |
| 92 | + } |
| 93 | + ``` |
| 94 | + |
| 95 | +6. **Build the project:** |
| 96 | + |
| 97 | + ```bash |
| 98 | + npm run build |
| 99 | + ``` |
| 100 | + |
| 101 | +7. **Serve the project locally:** |
| 102 | + |
| 103 | + ```bash |
| 104 | + php -S localhost:4646 -t dist |
| 105 | + ``` |
| 106 | + |
| 107 | + Visit `http://localhost:4646` in your browser to view the project. |
| 108 | + |
| 109 | +## 📄 Example Pages |
| 110 | + |
| 111 | +* **index.html:** The main landing page showcasing custom Tailwind styles. |
| 112 | +* **test.html:** A secondary page for testing purposes. |
| 113 | + |
| 114 | +## 📚 Resources |
| 115 | + |
| 116 | +* [Tailwind CSS Documentation](https://tailwindcss.com/docs) |
| 117 | +* [Vite Documentation](https://vitejs.dev/) |
| 118 | + |
| 119 | +## 📄 License |
| 120 | + |
| 121 | +This project is licensed under the MIT License. |
| 122 | + |
| 123 | +Copyright 2025, Max Base |
0 commit comments