Tailwind CSS
Install
================================= Tailwind CSS Install Step by Step ================================= Install Node js. check node -v and npm -v in cmd. Minimum recommended: Node.js: v16+ npm: v7+ If your version is lower, update Node.js from: 👉 https://nodejs.org/ ✅ Step 1: Create a Folder name: my-tailwind-project Open cmd with proper folder path C:\my-tailwind-project ✅ Step 2: => npm init -y it will create package.json. Modify / Add: "scripts": { "build": "postcss css/main.css -o css/style.css --watch" } ✅ Step 3: Install Tailwind, PostCSS, Autoprefixer => npm install -D tailwindcss postcss postcss-cli autoprefixer Creates package-lock.json and node_modules. ✅ Step 4: Generate tailwind.config.js file. => npx tailwindcss init -p (sometimes it will not work in windows). if not working with this command follow these steps: Create "tailwind.config.js" manually and paste: module.exports = { content: ["./*.html", "./css/*.css"], darkMode: false, // or 'media' or 'class' theme: { extend: {}, }, variants: { extend: {}, }, plugins: [], } ✅ Step 5: Create "postcss.config.js" manually and paste: module.exports = { plugins: { tailwindcss: {}, autoprefixer: {}, } } ✅ Step 5: Create main.css file into css folder. @tailwind base; @tailwind components; @tailwind utilities; ✅ Step 6: Create your HTML file 📄 index.html (example):
Tailwind Test
Hello Tailwind!
✅ Step 8: npx tailwindcss -i ./css/main.css -o ./css/style.css --watch == DONE ========================== Custom Font Use (example) ========================== create a fonts folder and put SourGummy.ttf. input.css ---------- @font-face { font-family: "Sour Gummy"; src: url('../fonts/SourGummy.ttf') format('truetype'); font-weight: normal; font-style: normal; } @tailwind base; @tailwind components; @tailwind utilities; npx tailwindcss-cli -i ./css/input.css -o ./css/output.css --watch and, tailwind.config.js ------------------- module.exports = { content: ["./*.html", "./css/*.css"], theme: { extend: { fontFamily: { sourGummy: ['"Sour Gummy"', 'sans-serif'], }, }, }, plugins: [], } index.html ----------
This is using MyFont!
or write in input.css, h1{font-family: "Sour Gummy";} ============= Customize CSS ============= .my-button { @apply bg-blue-500 text-white py-2 px-4 rounded hover:bg-blue-600; }
Click Me
===================================================== Customize HTML (hover, class, own style example => "py-[100px]") =====================================================