Tailwind CSS Basics for Beginners: A Hands-On Practical Guide
A beginner Tailwind CSS guide with a real practice project you can build and get feedback on.
Overviewh2
If you’re doing front-end work, chances are narinig mo na ang Tailwind CSS. It’s a utility-first CSS framework na sobrang useful lalo na kung ayaw mo mag code ng paulit-ulit na custom CSS.
Instead of writing your own styles from scratch, you compose your UI directly in HTML using utility classes. Medyo weird sa umpisa, pero once masanay ka, sobrang bilis mo na makakapag-prototype ng UI.
What is Tailwind CSS?h2
Tailwind CSS gives you small, single-purpose classes like:
p-4,m-2for spacingtext-xl,font-boldfor typographybg-blue-500,text-gray-700for colors
You apply them directly sa HTML elements. No need mag-isip ng class names, no need mag-jump pabalik-balik sa CSS file, direct ka na mag-eedit sa component or element.
Why Developers Likeh2
-
Highly customizable (Tailwind v4) – Sa Tailwind v4, mas simple na ang customization. Colors, fonts, spacing, at design tokens ay pwede nang i-define direkta sa main CSS file gamit ang
@themeat CSS variables, instead na satailwind.config.jska magco-configure. Mas malapit na siya sa standard CSS workflow, mas madaling i-maintain. -
Fast development – Once memorized mo na yung common utilities, sobrang bilis mag-layout at magdesign ng UI.
-
No class naming stress – Utility-first approach means hindi mo na kailangang mag-isip ng kung anu-anong class names tulad ng
button-1,button-primary-v2, etc. Mas malinaw kung ano ang ginagawa ng element just by reading the HTML. -
Responsive by default – Mobile-first ang mindset ng Tailwind. Madaling mag-scale ng layout from small screens to large screens gamit lang ang breakpoint prefixes.
-
Production optimized – Only the utilities you actually use are included sa final build. Pag na-compile na, hindi kasama yung unused classes, kaya mas maliit ang CSS file size.
-
Strong community – Solid ang documentation, madaming real-world examples, at kung may problema ka, mataas ang chance na may YouTube video, blog post, o GitHub discussion na tungkol dito.
Downsides (Real Talk)h2
- Learning curve - Lalo na kung sanay ka sa traditional CSS
- HTML can get long - Kapag di ka disciplined, hahaba ang class list
These aren’t deal breakers, pero good to be aware of them.
When Makes Senseh2
works best if:
- You build UI fast (prototypes, internal tools, dashboards)
- You care about consistency across components
- You’re working with component-based frameworks
- You don’t want to fight CSS specificity anymore
Framework Compatibilityh2
works well with:
- React
- Vue
- Angular
- Laravel Blade
- Even plain HTML
Basically, kung may HTML, pwede si Tailwind. Pero mas beneficial siya kung gagamitin mo component based frameworks like react, vue and svelte, sige kasama angular, kasi pwede mo reuse yung components/elements na ginawa mo, hindi mo na uulitin yung code.
Getting Startedh2
Prerequisitesh3
- Basic HTML and CSS knowledge
- A decent code editor (VS Code recommended)
- Node.js (for the CLI and build process)
Installation (Tailwind v4 Style)h2
1. Project Initializationh3
I-set up ang project folder
make sure na installed node.js na may latest version
npm init -ynpm install tailwindcss @tailwindcss/clinpm - meaning node package manager this is a tool naginagamit para makapag install ka ng libraries
init - Start / Pag-set up ng folder (Initialization)
-y - short cut for yes, meaning it will accept all the default values
tailwindcss - tailwind css library
@tailwindcss/cli - tailwind css command line interface
2. Create Files Structureh3
Create these files on your project folder:
tailwindcss-practice/├── node_modules/ # Auto-generated, dito nakalagay lahat ng installed libraries (npm install)├── public/ # Final output folder│ └── css/│ └── output.css # Auto-generated, compiled CSS (Eto yung naka-link sa HTML)├── src/ # Source folder (Dito ka mag-e-edit)│ ├── css/│ │ └── input.css # Raw CSS na may @import "tailwindcss";│ └── index.html # Main HTML file├── package.json # Auto-generated, project manifest / metadata└── package-lock.json # Auto-generated, version history ng mga installed packagessrc/ (Source): Dito nakalagay ang “raw” code mo. Hindi babasahin ng browser, dahil kailangan muna itong i-process ng tailwind CLI.
public/ (Distribution): Dito ilalagay ng Tailwind CLI ang “compiled” version. Ito ang folder na ready na i-upload sa internet or i-open sa browser.
Don’t create the auto-generated files, as indicated on the project folder structure.
3. Tailwind & Theme Configurationh3
Add Tailwind and theme config sa src/css/input.css:
@import "tailwindcss";
@theme { --color-primary: #7c3aed; --font-sans: ui-sans-serif, system-ui;}@import "tailwindcss"; - dito galing yung na library na gagamitin mo
@theme - Ito yung “container” kung saan mo sine-set up yung custom theme variables
--color-primary: #7c3aed; - define custom color variables
--font-sans: ui-sans-serif, system-ui; - define custom font variables
4. Connecting and Compiling Tailwindh3
I-link ang Compiled CSS: Ito yung file na babasahin ng browser mo. Make sure na tama yung path papunta sa file na ni-generate ng Tailwind. Pwede mong baguhin yung name ng input.css at output.css (that’s just a convention, you can name it anything you want).
<link href="../public/css/output.css" rel="stylesheet" />Run the watcher: This will watch for changes in the input file and recompile the output file when changes are detected.
npx @tailwindcss/cli -i ./src/css/input.css -o ./public/css/output.css --watchnpx - meaning node package executor
@tailwindcss/cli - anong library/package yung e-execute
-i - input file
-o - output file
--watch - watch for changes, pwede mo naman remove yung —watch if you want to run it once
Core Concepts You Should Learn Firsth2
1. Layouth3
Before mo matutunan yung colors, fonts, or animations, layout muna tayo. Ito yung sagot sa tanong na:
“Saan ilalagay o ipo-position yung mga elements?”
Sa Tailwind, 90% ng basic layouts ay kaya na ng tatlong concepts lang:
containerflexgrid
Let’s go through them one by one, with actual examples.
1.1. Container - Centered Page Layouth4
Ginagamit ang container kapag gusto mong i-center yung content na may max width, parang common website layout.
Example:
Page Title
This content is centered.
<div class="container mx-auto p-6 bg-gray-200"> <h1 class="text-2xl font-bold">Page Title</h1> <p>This content is centered.</p></div>Explanation:
container – may built-in max-width per screen size
mx-auto – center horizontally
p-6 – breathing space sa loob ng element
1.2. Flex - One-Dimensional Layout (Row or Column)h4
Flexbox is best kapag isa lang ang direction ng layout mo:
- row (horizontal)
- column (vertical)
Example 1: Horizontal Layout (Row)h5
<div class="flex gap-4 bg-gray-100 p-4"> <div class="bg-yellow-500 p-4 text-white">Item 1</div> <div class="bg-yellow-500 p-4 text-white">Item 2</div> <div class="bg-yellow-500 p-4 text-white">Item 3</div></div>What’s happening:
flex→ naka-row by default (horizontal)gap-4→ spacing between items
Flexbox Alignment Utilities (Horizontal Axis)h4
Once naka-flex ka na, pwede mo nang kontrolin paano naka-align ang items sa loob ng container.
Ito yung mga common justify-* utilities na ginagamit para sa horizontal alignment:
justify-start
justify-end
justify-center
justify-between
justify-around
justify-evenly
justify-stretch
These utilities control space distribution, hindi size ng items:
justify-start → items stick to the left
justify-center → items are centered
justify-end → items stick to the right
justify-between → space is placed between items
justify-around → equal space around each item
justify-evenly → equal space everywhere
justify-stretch → items are stretched to fill the container
🧠 Important mental model:
Flexbox is not about positioning elements, it’s about distributing space.
1.3. Grid - Two-Dimensional Layout (Rows and Columns)h4
Kung ang Flexbox pang-isang direction lang, ang Grid naman ay pang-rows at columns sabay. Ito ang reason kung bakit mas bagay ang Grid sa cards, dashboards, at page sections.
Sa Tailwind, mabilis mo syang ma-visualize once nakita mo yung patterns.
Example 1: Grid Columns and Rowsh5
<div class="grid grid-cols-3 gap-4 bg-gray-100 p-4"> <div class="bg-yellow-500 p-4 text-white">1</div> <div class="bg-yellow-500 p-4 text-white">2</div> <div class="bg-yellow-500 p-4 text-white">3</div> <div class="bg-yellow-500 p-4 text-white">4</div> <div class="bg-yellow-500 p-4 text-white">5</div> <div class="bg-yellow-500 p-4 text-white">6</div></div>What’s happening:
grid → enable CSS Grid
grid-cols-3 → 3 equal columns
gap-4 → spacing between grid cells
rows are created automatically as items increase
🔑 Key idea:
You define the columns. Grid handles the rows.
Example 2: Grid Alignment (place-items-*)h5
Grid has its own alignment system. Unlike Flexbox, alignment here happens inside each grid cell.
place-items-start
place-items-center
place-items-end
place-items-stretch (default)
<div class="grid grid-cols-3 h-40 place-items-center bg-gray-100 p-4"> <div class="bg-yellow-500 p-4 text-white">Item</div> <div class="bg-yellow-500 p-4 text-white">Item</div> <div class="bg-yellow-500 p-4 text-white">Item</div></div>Common values:
place-items-startplace-items-centerplace-items-endplace-items-stretch (default)
🧠 Mental model:
- Flex aligns items as a group.
- Grid aligns items per cell.
Example 3: Grid Item Spanning (col-span-*)h5
Ito yung part kung saan talaga ginagamit ang Grid.
<div class="grid grid-cols-3 gap-4 bg-gray-100 p-4"> <div class="col-span-2 bg-yellow-500 p-4 text-white">col-span-2</div> <div class="row-span-2 bg-yellow-500 p-4 text-white">Item</div> <div class="bg-yellow-500 p-4 text-white">Item</div> <div class="col-span-3 bg-yellow-500 p-4 text-white">col-span-3</div></div>Explanation:
col-span-2 → item takes 2 columns
col-span-3 → item takes 3 columns (full row)
row-span-2 → item takes 2 rows
No hacks. No math. No breaking layouts.
When to Use Gridh5
Use Grid when:
- may columns ka na iniisip
- may cards or sections na may structure
- kailangan ng responsive layout without complexity
- may elements na kailangang mag-span ng space
👇 Bottom line:
- Kung alignment lang ang concern mo →
Flex- Kung layout structure ang concern mo →
Grid
Kapag gets mo na yung difference, madali na sayo mag-layout at predictable na yung behavior ng elements.
2. Spacing - Margin, Padding, and Borderh3
Spacing is use to create breathing room in the layout. Sa Tailwind, hindi ka gagamit pixels, kung hindi scale.
Most spacing utilities follow this pattern:
<property>-<value>Where the value usually ranges from: 0, 1, 2, 3, 4, 6, 8, 10, 12, 16…
2.1. Margin (Space sa Labas ng Element)h4
<div class="mt-6 mb-4"> Margin example</div>Common margin utilities:
m-4→ margin sa lahat ng sidesmt-6→ margin-topmb-4→ margin-bottommx-auto→ auto margin left & right (pang-center)
Rule:
Margin separates elements from each other.
2.2. Padding (Space sa Loob ng Element)h4
<button class="px-6 py-3"> Button</button>Common padding utilities:
p-4→ padding sa lahat ng sidespx-6→ left & right paddingpy-3→ top & bottom padding
Mas mataas na value → mas malaki yung space ng side sa loob ng element.
2.3. Border (Visual Separation)h4
<div class="border border-gray-300 rounded-md p-4"> Box with border</div>Border utilities you’ll often use:
border→ enable borderborder-2→ border thicknessborder-gray-300→ border colorrounded-sm | md | lg | full→ border radius
2.4. Space Utilities (space-x-, space-y-)h4
space-* utilities add consistent spacing between direct children.
<div class="space-y-4"> <div class="bg-gray-100 p-4">Item 1</div> <div class="bg-gray-100 p-4">Item 2</div> <div class="bg-gray-100 p-4">Item 3</div></div>Common usage:
space-y-4→ vertical spacingspace-x-6→ horizontal spacing (for flex-row)
Why this mattersh5
Mas malinis ito kaysa maglagay ng mb-* sa bawat item.
Changeable Values (Important pattern)h5
Most spacing and border utilities accept the same scale values, so madaling tandaan. Examples:
p-2,p-4,p-8mt-2,mt-6,mt-12space-y-2,space-y-6border,border-2,border-4
💡 Once alam mo na yung pattern, hindi mo na kailangan makabisado lahat.
🧠 Quick Mental Model:
- Margin → labas
- Padding → loob
- Border → boundary
- Space → between siblings
Kapag nasanay ka na sa spacing utilities, layout decisions become faster and cleaner.
3. Typography - Controlling How Text Feelsh3
Typography is not just about making text bigger or bolder. It’s about readability, hierarchy, and emphasis.
Sa Tailwind, typography is handled using utility classes, so you don’t need to jump back and forth sa CSS file just to adjust text styles.
3.1. Font Size (Text Scale)h4
Font size utilities follow a semantic scale, hindi arbitrary values.
Small text (text-sm)
Base text (text-base)
Large text (text-xl)
Very Large text (text-3xl)
<div class="space-y-2"> <p class="text-sm">Small text (text-sm)</p> <p class="text-base">Base text (text-base)</p> <p class="text-xl">Large text (text-xl)</p> <p class="text-xl">Very Large text (text-3xl)</p></div>Common sizes you’ll use most of the time:
text-sm→ captions, hintstext-base→ body text (default)text-xl→ section titlestext-3xl→ page headings
Tip: Stick to the scale. It keeps your UI visually consistent.
3.2. Font Weight (Emphasis)h4
Font weight controls importance, not decoration.
font-light
font-normal
font-semibold
font-bold
<div class="space-y-2"> <p class="font-light">font-light</p> <p class="font-normal">font-normal</p> <p class="font-semibold">font-semibold</p> <p class="font-bold">font-bold</p></div>Common usage:
font-normal → body text
font-semibold → labels, subheadings
font-bold → headings, emphasis
⚠️ Avoid using font-bold everywhere - kapag lahat bold, walang bold. Wowie wowie.
3.3. Text Alignmenth4
Text alignment controls how content is read, not how it looks.
Left aligned text
Centered text
Right aligned text
<div class="space-y-2"> <p class="text-left">Left aligned text</p> <p class="text-center">Centered text</p> <p class="text-right">Right aligned text</p></div>Guidelines:
text-left→ paragraphs, long contenttext-center→ headings, empty statestext-right→ numbers, metadata
3.4. Line Height (Leading)h4
Line height affects readability, especially sa paragraphs
Tight line height. Mas dikit ang lines. Tight line height. Mas dikit ang lines. Tight line height. Mas dikit ang lines.
Normal line height. Default and readable. Normal line height. Default and readable. Normal line height. Default and readable.
Relaxed line height. Mas comfy basahin. Relaxed line height. Mas comfy basahin. Relaxed line height. Mas comfy basahin.
<div class="space-y-4"> <p class="leading-tight"> Tight line height. Mas dikit ang lines. </p> <p class="leading-normal"> Normal line height. Default and readable. </p> <p class="leading-relaxed"> Relaxed line height. Mas comfy basahin. </p></div>👍 Rule of thumb:
Headings→ leading-tightParagraphs→ leading-normal or leading-relaxed
3.5. Text Color (Readability First)h4
Typography is incomplete without proper contrast.
Primary text
Secondary text
Muted text
<div class="space-y-2"> <p class="text-gray-900">Primary text</p> <p class="text-gray-600">Secondary text</p> <p class="text-gray-400">Muted text</p></div>Avoid pure black (#000) for body text
gray scales are easier on the eyes.
Typography Hierarchy (Very Important)h5
A simple, practical hierarchy might look like this:
<h1 class="text-3xl font-bold">Page Title</h1><h2 class="text-xl font-semibold">Section Title</h2><p class="text-base text-gray-700"> Body text goes here.</p>🧠 Mental model:
- Size shows importance.
- Weight shows emphasis.
- Color shows priority.
Quick Takeawaysh4
Typography in Tailwind is:
- predictable
- consistent
- scale-based
Once you stop thinking in pixels and start thinking in roles (heading, body, label), your UI instantly feels more professional.
4. Colors - Using Color with Purposeh3
Colors in Tailwind are not random hex values. They follow a design scale, so everything feels consistent out of the box.
Instead of guessing colors, you pick from a palette.
4.1. Text Colorsh4
Primary text
Secondary text
Muted text
<div class="space-y-2"> <p class="text-gray-900">Primary text</p> <p class="text-gray-700">Secondary text</p> <p class="text-gray-500">Muted text</p></div>Explanation:
text-gray-900 → strong emphasis
text-gray-700 → normal body text
text-gray-500 → helper or secondary info
Tip:
Use darker colors for importance, lighter colors for context.
4.2. Background Colorsh4
<div class="space-y-2"> <div class="bg-white p-4">White background</div> <div class="bg-gray-100 p-4">Light gray background</div> <div class="bg-gray-200 p-4">Section background</div></div>Common usage:
bg-white → main content
bg-gray-100 → page background
bg-gray-200 → cards or sections
4.3. Using Brand Colorsh4
Tailwind colors follow this pattern:
<color-name>-<intensity> bg-gray-100 text-gray-100<div class="space-y-2"> <div class="bg-blue-500 text-white p-4">Primary action</div> <div class="bg-green-500 text-white p-4">Success state</div> <div class="bg-red-500 text-white p-4">Error state</div></div>Intensity scale usually goes from:
100→ very light500→ base color900→ very dark
4.4. Hover and State Colorsh4
Colors become more useful once may interaction na.
<button class="bg-blue-500 hover:bg-blue-600 text-white px-6 py-2"> Hover me</button>Pattern to remember:
base → *-500
hover → *-600 or *-700
You’ll see:
- all color names
- all intensity levels
- visual swatches
- usage examples
💡 You don’t need to memorize these. You just need to know where to look.
4.5. Seeing All Available Colorsh4
ships with a complete color palette ready to use.
👉 View the full color reference here: https://.com/docs/customizing-colors
When to Customize Colorsh5
Default colors are already good enough for most projects.
Customize only when:
-
you have a brand color
-
you want consistent theming
-
you’re building a design system
Example (from earlier):
@theme { --color-primary: #7c3aed;}Then use it like:
<div class="bg-primary text-white p-4"> Primary section</div>Quick Takeawayh5
Colors in Tailwind are about consistency, not creativity.
Once you follow the scale:
- your UI looks cleaner
- contrast improves
- maintenance becomes easier
5. Responsive Utilities - Designing for All Screen Sizesh3
Hindi na optional ang responsiveness. Sa Tailwind, built-in na ito and follows a mobile-first approach.
Meaning:
Default styles apply to small screens, then you layer changes as screen size grows.
Tailwind Breakpoints (Default)h4
These are the breakpoints you’ll use most often:
sm: → small screens (phones, large phones)
md: → tablets
lg: → laptops
xl: → desktops
2xl: → large monitors
You don’t need to memorize exact pixel values. Just remember small → large.
5.1. Responsive Texth5
Responsive Heading
<h1 class="text-xl md:text-3xl lg:text-5xl"> Responsive Heading</h1>What happens:
- Mobile →
text-xl - Tablet →
text-3xl - Desktop →
text-5xl
Same element. Different sizes. No media queries. Actually di na bago to, most CSS libraries use same pattern gaya nito.
5.2. Responsive Layout (Grid)h5
<div class="grid grid-cols-1 md:grid-cols-3 gap-4"> <div class="bg-gray-100 p-4">Card</div> <div class="bg-gray-100 p-4">Card</div> <div class="bg-gray-100 p-4">Card</div></div>Behavior:
- Mobile → stacked cards
- Tablet & up → 3 columns
5.3. Responsive Spacingh4
<div class="p-4 md:p-8 lg:p-12"> Responsive padding</div>Sa Mobile Screen mas maliit yung padding p-4, sa Tablet p-8, sa Desktop mas malaki p-12.
5.4. Responsive Flex Directionh4
<div class="flex flex-col md:flex-row gap-4"> <div class="bg-gray-100 p-4">Item</div> <div class="bg-gray-100 p-4">Item</div></div>- Mobile → vertical
- Desktop → horizontal
Common Pattern (Important)h5
base-class md:override lg:overrideExampleh5
text-sm md:text-base lg:text-lggrid-cols-1 md:grid-cols-2 lg:grid-cols-4p-4 md:p-6
💡 Tip:
Start small, then add complexity as screen size increases.
Wrap-Up: Putting It All Togetherh2
Kung nakaabot ka dito, congrats 👏.
You’ve learned the core ideas behind .
Hindi mo pa alam lahat? that’s perfectly fine. Hindi rin naman yun ang goal ng guide na ‘to.
Ang importante, gets mo na kung paano gumagana si Tailwind:
- layout (Flex and Grid)
- spacing
- typography
- colors
- responsiveness
Once nag-click ’yan, the rest becomes muscle memory. You stop asking “anong class ang kailangan?” and start asking “anong layout behavior ang gusto ko?”
Mas focus ka sa designing and layout decisions kaysa sa classes.
Tailwind is not about writing less CSS. It’s about making layout decisions explicit.
And that mindset is what makes you faster over time.
Practice Your Knowledgeh2
Kung gusto mong i-test kung nag-sink in talaga yung mga concepts, I created a repo for you to practice.
👉 https://github.com/enehry/tailwindcss-practice
This repository is designed as a UI cloning exercise. The goal is simple:
recreate the provided sample UI as close as possible using Tailwind CSS v4 (CLI).
Inside the repo, you’ll find:
- A sample UI image (
task-tailwind.png) that serves as your visual reference - A basic project structure
- Image assets you must use in the layout
- A
READMEthat explains how to set up Tailwind v4 using the CLI
Your focus should be on matching the UI in terms of:
- layout
- spacing
- colors
- typography
- responsive behavior
This is not a guided tutorial, it’s meant to simulate a real-world front-end task where you translate a design into code.
- Look at the UI.
- Break it down into sections.
- Decide whether to use Flex or Grid.
- Apply spacing and typography intentionally.
If you can recreate the layout cleanly and make it responsive without fighting the framework, you’re already doing well.
If you want feedback, you can open an issue in the repository and include a link to your code. I’ll be happy to take a look 😄 and star the repo if you find it useful ⭐. Thank you!
Final Thoughtsh2
Tailwind CSS is not magic, but once matutunan mo to’, mahirap nang bumalik sa traditional way ng pag-design ng UI.
My suggestion: learn the basics, practice lang nang practice, try mo replicate yung UI ng ibang website para ma-challenge ka, and don’t try to memorize everything at once - di naman yan exam.
Darating ka din sa point na:
Basic, Kaya ko na to’ i-design from scratch. Kaya ko na mag-replicate ng UI kahit anong itsura pa yan. Mabilis ko lang to i-pprototype at matic responsive and mobile first to.
Di mo ‘yan mapapansin, pero malalaman mo na nandun ka na kapag mas mabilis mo nang natatapos yung layout mo kaysa sa kape mo ☕😄.
P.Sh3
Huwag mo munang gamitan ng AI ’to habang nagpa-practice. Ang goal dito ay mahasa yung fundamentals at yung way mo ng pag-iisip sa pag la-layout.
Kapag na master mo si Tailwind at gets mo na yung patterns, saka mo gamitin yung AI, mas magiging useful siya kasi alam mo na kung ano ang ite-take at ano ang idi-discard.
AI is a tool. Foundations still matter.