12/05/2026 01:14am

EP 2: What is Utility-First? Understanding Tailwind's Class System Like a Pro
#Class System
#Tailwind CSS Classes
#Tailwind CSS
#Utility-First CSS
After EP 1 where we got to know Tailwind CSS and understood why it's become so popular, today we'll dive deep into the core concept that makes Tailwind CSS different from other CSS frameworks: "Utility-First"
Have you ever wondered why Tailwind CSS uses the Utility-First approach? How is it better than traditional CSS? And most importantly - how can we remember all these classes?
Today we'll answer these questions with expert techniques for memorizing classes and tips that will help you write Tailwind CSS like a professional!
What is Utility-First? Why It's a Game-Changer for CSS
Core Principles of Utility-First
Utility-First is a CSS design approach that uses small, single-purpose classes to compose complex designs, rather than writing component-specific CSS in separate files.
Instead of writing this:
/* Traditional (Component-First) */
.hero-section {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
padding: 4rem 2rem;
text-align: center;
color: white;
}
.hero-title {
font-size: 3rem;
font-weight: bold;
margin-bottom: 1rem;
line-height: 1.2;
}
.hero-button {
background-color: #ffffff;
color: #667eea;
padding: 0.75rem 2rem;
border-radius: 0.5rem;
border: none;
font-weight: 600;
transition: all 0.3s ease;
}
.hero-button:hover {
background-color: #f1f5f9;
transform: translateY(-2px);
}
We write this:
<!-- New Way (Utility-First) -->
<section class="bg-gradient-to-br from-indigo-500 to-purple-600 py-16 px-8 text-center text-white">
<h1 class="text-5xl font-bold mb-4 leading-tight">
Welcome to the Future
</h1>
<button class="bg-white text-indigo-500 px-8 py-3 rounded-lg font-semibold hover:bg-gray-100 hover:-translate-y-0.5 transition-all duration-300">
Get Started
</button>
</section>
Why is Utility-First Different?
1. Speed of Development
- No need to think of class names
- No switching between files
- Instant changes
2. Flexibility
- Create unlimited designs
- Not constrained by predefined components
- Fine-grained control
3. Consistency
- Uses a consistent design system
- Standardized colors and sizing
- Reduces design mistakes
Here's an example of creating a complex card:
<div class="max-w-sm mx-auto bg-white rounded-xl shadow-lg overflow-hidden md:max-w-2xl">
<div class="md:flex">
<div class="md:shrink-0">
<img class="h-48 w-full object-cover md:h-full md:w-48" src="/img/building.jpg" alt="Modern building architecture">
</div>
<div class="p-8">
<div class="uppercase tracking-wide text-sm text-indigo-500 font-semibold">Company retreat</div>
<a href="#" class="block mt-1 text-lg leading-tight font-medium text-black hover:underline">Incredible accommodation for your team</a>
<p class="mt-2 text-slate-500">Looking to take your team away on a retreat to enjoy awesome food and take in some sunshine? We have a list of places to do just that.</p>
</div>
</div>
</div>
Tailwind CSS Class Categories
1. Layout Classes - Structure Management
Container and Display
<!-- Container -->
<div class="container mx-auto">Sets max-width and centers content</div>
<!-- Display -->
<div class="block">display: block</div>
<div class="inline-block">display: inline-block</div>
<div class="inline">display: inline</div>
<div class="flex">display: flex</div>
<div class="grid">display: grid</div>
<div class="hidden">display: none</div>
Flexbox System
<!-- Flex Direction -->
<div class="flex flex-row">Horizontal (default)</div>
<div class="flex flex-col">Vertical</div>
<div class="flex flex-row-reverse">Horizontal reversed</div>
<!-- Justify Content -->
<div class="flex justify-start">Align left</div>
<div class="flex justify-center">Center</div>
<div class="flex justify-between">Space between</div>
<div class="flex justify-around">Space around</div>
<!-- Align Items -->
<div class="flex items-start">Align top</div>
<div class="flex items-center">Center vertically</div>
<div class="flex items-end">Align bottom</div>
Grid System
<!-- Grid Template Columns -->
<div class="grid grid-cols-1">1 column</div>
<div class="grid grid-cols-2">2 columns</div>
<div class="grid grid-cols-3">3 columns</div>
<div class="grid grid-cols-12">12 columns</div>
<!-- Grid Gap -->
<div class="grid grid-cols-3 gap-4">1rem gap</div>
<div class="grid grid-cols-3 gap-x-4 gap-y-2">Separate horizontal-vertical gaps</div>
<!-- Grid Span -->
<div class="col-span-2">Span 2 columns</div>
<div class="row-span-3">Span 3 rows</div>
2. Spacing Classes - Distance Management
Padding and Margin System
<!-- Padding (p = padding) -->
<div class="p-4">padding: 1rem (all sides)</div>
<div class="px-4">padding: 0 1rem (left-right)</div>
<div class="py-4">padding: 1rem 0 (top-bottom)</div>
<div class="pt-4">padding-top: 1rem</div>
<div class="pr-4">padding-right: 1rem</div>
<div class="pb-4">padding-bottom: 1rem</div>
<div class="pl-4">padding-left: 1rem</div>
<!-- Margin (m = margin) -->
<div class="m-4">margin: 1rem (all sides)</div>
<div class="mx-auto">margin: 0 auto (center)</div>
<div class="my-8">margin: 2rem 0 (top-bottom)</div>
<div class="mt-4">margin-top: 1rem</div>
<div class="-mt-4">margin-top: -1rem (negative)</div>
Standard Size System
0 = 0px
0.5 = 0.125rem (2px)
1 = 0.25rem (4px)
1.5 = 0.375rem (6px)
2 = 0.5rem (8px)
2.5 = 0.625rem (10px)
3 = 0.75rem (12px)
3.5 = 0.875rem (14px)
4 = 1rem (16px)
5 = 1.25rem (20px)
6 = 1.5rem (24px)
7 = 1.75rem (28px)
8 = 2rem (32px)
9 = 2.25rem (36px)
10 = 2.5rem (40px)
11 = 2.75rem (44px)
12 = 3rem (48px)
14 = 3.5rem (56px)
16 = 4rem (64px)
20 = 5rem (80px)
24 = 6rem (96px)
28 = 7rem (112px)
32 = 8rem (128px)
36 = 9rem (144px)
40 = 10rem (160px)
44 = 11rem (176px)
48 = 12rem (192px)
52 = 13rem (208px)
56 = 14rem (224px)
60 = 15rem (240px)
64 = 16rem (256px)
72 = 18rem (288px)
80 = 20rem (320px)
96 = 24rem (384px)
3. Color System
Main Color Types
<!-- Background Colors -->
<div class="bg-red-500">Red background</div>
<div class="bg-blue-600">Blue background</div>
<div class="bg-green-400">Green background</div>
<!-- Text Colors -->
<p class="text-gray-800">Dark gray text</p>
<p class="text-indigo-500">Indigo text</p>
<!-- Border Colors -->
<div class="border border-red-300">Light red border</div>
Color Intensity Levels
<!-- Gray Scale -->
<div class="bg-gray-50">Very light gray</div>
<div class="bg-gray-100">Light gray</div>
<div class="bg-gray-200">Light-medium gray</div>
<div class="bg-gray-300">Medium gray</div>
<div class="bg-gray-400">Medium-dark gray</div>
<div class="bg-gray-500">Dark gray</div>
<div class="bg-gray-600">Darker gray</div>
<div class="bg-gray-700">Very dark gray</div>
<div class="bg-gray-800">Extra dark gray</div>
<div class="bg-gray-900">Almost black</div>
<!-- Blue Scale -->
<div class="bg-blue-50">Very light blue</div>
<div class="bg-blue-100">Light blue</div>
<div class="bg-blue-500">Standard blue</div>
<div class="bg-blue-900">Very dark blue</div>
Special Colors and Gradients
<!-- Black-White -->
<div class="bg-white">White background</div>
<div class="bg-black">Black background</div>
<div class="bg-transparent">Transparent background</div>
<!-- Gradients -->
<div class="bg-gradient-to-r from-purple-500 to-pink-500">Left-right gradient</div>
<div class="bg-gradient-to-br from-green-400 to-blue-600">Bottom-right gradient</div>
<div class="bg-gradient-to-t from-yellow-400 via-red-500 to-pink-500">3-color gradient</div>
4. Typography Classes - Text Management
Font Size and Weight
<!-- Font Size -->
<p class="text-xs">12px - Extra small</p>
<p class="text-sm">14px - Small</p>
<p class="text-base">16px - Normal (default)</p>
<p class="text-lg">18px - Large</p>
<p class="text-xl">20px - Extra large</p>
<p class="text-2xl">24px - Small heading</p>
<p class="text-3xl">30px - Medium heading</p>
<p class="text-4xl">36px - Large heading</p>
<p class="text-5xl">48px - Extra large heading</p>
<p class="text-6xl">60px - Huge heading</p>
<!-- Font Weight -->
<p class="font-thin">100 - Extra thin</p>
<p class="font-light">300 - Light</p>
<p class="font-normal">400 - Normal</p>
<p class="font-medium">500 - Medium</p>
<p class="font-semibold">600 - Semi-bold</p>
<p class="font-bold">700 - Bold</p>
<p class="font-black">900 - Extra bold</p>
Alignment and Spacing
<!-- Text Alignment -->
<p class="text-left">Left aligned</p>
<p class="text-center">Center aligned</p>
<p class="text-right">Right aligned</p>
<p class="text-justify">Justified</p>
<!-- Line Height -->
<p class="leading-tight">Tight line spacing</p>
<p class="leading-normal">Normal line spacing</p>
<p class="leading-loose">Loose line spacing</p>
<!-- Letter Spacing -->
<p class="tracking-tight">Tight letter spacing</p>
<p class="tracking-normal">Normal letter spacing</p>
<p class="tracking-wide">Wide letter spacing</p>
Text Decoration
<!-- Text Decoration -->
<p class="underline">Underlined</p>
<p class="line-through">Strike-through</p>
<p class="no-underline">No underline</p>
<!-- Text Transform -->
<p class="uppercase">ALL UPPERCASE</p>
<p class="lowercase">all lowercase</p>
<p class="capitalize">Capitalize Each Word</p>
<!-- Text Style -->
<p class="italic">Italic text</p>
<p class="not-italic">Not italic</p>
5. Border and Radius Classes
Borders
<!-- Border Width -->
<div class="border">1px border all sides</div>
<div class="border-2">2px border all sides</div>
<div class="border-4">4px border all sides</div>
<div class="border-t">Top border only</div>
<div class="border-r">Right border only</div>
<div class="border-b">Bottom border only</div>
<div class="border-l">Left border only</div>
<!-- Border Style -->
<div class="border border-solid">Solid border</div>
<div class="border border-dashed">Dashed border</div>
<div class="border border-dotted">Dotted border</div>
<div class="border-none">No border</div>
Border Radius
<!-- Rounded Corners -->
<div class="rounded-none">No rounded corners</div>
<div class="rounded-sm">Small rounded (2px)</div>
<div class="rounded">Normal rounded (4px)</div>
<div class="rounded-md">Medium rounded (6px)</div>
<div class="rounded-lg">Large rounded (8px)</div>
<div class="rounded-xl">Extra large rounded (12px)</div>
<div class="rounded-full">Full rounded (circle)</div>
<!-- Specific Corners -->
<div class="rounded-t-lg">Top corners rounded</div>
<div class="rounded-r-lg">Right corners rounded</div>
<div class="rounded-tl-lg">Top-left corner rounded</div>
<div class="rounded-tr-lg">Top-right corner rounded</div>
Expert Techniques for Memorizing Classes
1. Pattern Recognition
Naming Pattern
[property]-[direction]-[size]
[property]-[color]-[shade]
[breakpoint]:[property]-[value]
Examples:
mt-4= margin-top: 1rempx-6= padding-left: 1.5rem, padding-right: 1.5rembg-blue-500= background-color: #3b82f6md:text-lg= @media (min-width: 768px) { font-size: 1.125rem }
2. Common Class Combinations
Layout Combos
<!-- Center everything -->
<div class="flex items-center justify-center">
<!-- Basic card -->
<div class="bg-white rounded-lg shadow-md p-6">
<!-- Responsive container -->
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<!-- Responsive grid -->
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
Typography Combos
<!-- Main heading -->
<h1 class="text-3xl md:text-4xl font-bold text-gray-900">
<!-- Secondary text -->
<p class="text-lg text-gray-600 leading-relaxed">
<!-- Button -->
<button class="bg-blue-500 hover:bg-blue-600 text-white font-medium px-6 py-3 rounded-lg transition-colors">
3. Mnemonics Technique
Direction
t= Topr= Rightb= Bottoml= Leftx= X-axis (left-right)y= Y-axis (top-bottom)
Size
0= None1-3= Small4-6= Medium8-12= Large16+= Extra large
4. Create Your Own System
Group by Function
/* Use @apply to create class groups */
@layer components {
.layout-center {
@apply flex items-center justify-center;
}
.layout-container {
@apply max-w-7xl mx-auto px-4 sm:px-6 lg:px-8;
}
.text-heading {
@apply text-3xl font-bold text-gray-900;
}
.text-body {
@apply text-base text-gray-600 leading-relaxed;
}
.btn-primary {
@apply bg-blue-500 hover:bg-blue-600 text-white font-medium px-6 py-3 rounded-lg transition-colors;
}
.card-basic {
@apply bg-white rounded-lg shadow-md p-6;
}
}
Responsive Design with Breakpoint System
Tailwind Breakpoints
<!-- Default (Mobile First) -->
<div class="text-sm">Small text on all screen sizes</div>
<!-- sm: >= 640px -->
<div class="text-sm sm:text-base">Small on mobile, normal on tablet</div>
<!-- md: >= 768px -->
<div class="text-sm md:text-lg">Small on mobile, large on tablet</div>
<!-- lg: >= 1024px -->
<div class="text-sm lg:text-xl">Small on mobile, extra large on desktop</div>
<!-- xl: >= 1280px -->
<div class="text-sm xl:text-2xl">Small on mobile, huge on large desktop</div>
<!-- 2xl: >= 1536px -->
<div class="text-sm 2xl:text-3xl">Small on mobile, massive on extra large desktop</div>
Real-World Examples
Responsive Navigation
<nav class="bg-white shadow-lg">
<div class="max-w-7xl mx-auto px-4">
<div class="flex justify-between items-center py-4">
<!-- Logo -->
<div class="flex items-center">
<img class="h-8 w-auto" src="/logo.svg" alt="Logo">
</div>
<!-- Desktop Menu -->
<div class="hidden md:flex space-x-8">
<a href="#" class="text-gray-600 hover:text-gray-900">Home</a>
<a href="#" class="text-gray-600 hover:text-gray-900">About</a>
<a href="#" class="text-gray-600 hover:text-gray-900">Contact</a>
</div>
<!-- Mobile Menu Button -->
<div class="md:hidden">
<button class="text-gray-600 hover:text-gray-900 focus:outline-none">
<svg class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16" />
</svg>
</button>
</div>
</div>
</div>
</nav>
Responsive Hero Section
<section class="bg-gradient-to-r from-blue-600 to-purple-600 text-white">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12 sm:py-16 lg:py-24">
<div class="text-center">
<h1 class="text-3xl sm:text-4xl md:text-5xl lg:text-6xl font-bold mb-4 sm:mb-6">
Build Amazing Websites
</h1>
<p class="text-lg sm:text-xl md:text-2xl mb-6 sm:mb-8 max-w-3xl mx-auto">
With Tailwind CSS Framework that makes web development 10x faster
</p>
<div class="flex flex-col sm:flex-row gap-4 justify-center">
<button class="bg-white text-blue-600 px-6 sm:px-8 py-3 rounded-lg font-medium hover:bg-gray-100 transition-colors">
Get Started Free
</button>
<button class="border-2 border-white text-white px-6 sm:px-8 py-3 rounded-lg font-medium hover:bg-white hover:text-blue-600 transition-colors">
View Examples
</button>
</div>
</div>
</div>
</section>
State Variants - Managing Different States
Hover, Focus, and Active States
<!-- Hover Effects -->
<button class="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded">
Hover color change
</button>
<div class="transform hover:scale-105 transition-transform">
Hover scale up
</div>
<a href="#" class="text-blue-500 hover:text-blue-700 hover:underline">
Hover color and underline
</a>
<!-- Focus Effects -->
<input class="border border-gray-300 focus:border-blue-500 focus:ring-2 focus:ring-blue-200 px-3 py-2 rounded"
type="text" placeholder="Focus changes color">
<button class="bg-green-500 focus:bg-green-600 focus:outline-none focus:ring-4 focus:ring-green-200 text-white px-4 py-2 rounded">
Focus Button
</button>
<!-- Active Effects -->
<button class="bg-red-500 active:bg-red-700 text-white px-4 py-2 rounded">
Active color change
</button>
<!-- Group Hover (effects when hovering parent) -->
<div class="group bg-white p-6 rounded-lg hover:bg-gray-50">
<h3 class="text-gray-900 group-hover:text-blue-600">Title</h3>
<p class="text-gray-600 group-hover:text-gray-700">Description</p>
</div>
Responsive States
<!-- Responsive Hover (hover only on desktop) -->
<button class="bg-blue-500 md:hover:bg-blue-600 text-white px-4 py-2 rounded">
Hover only on Desktop
</button>
<!-- Combined Responsive + State -->
<div class="text-sm md:text-base hover:text-lg md:hover:text-xl">
Size changes by breakpoint and hover
</div>
Dark Mode Support
⚠️ Note: Dark Mode must be enabled in tailwind.config.js first:
// tailwind.config.js
module.exports = {
darkMode: 'class', // or 'media'
// ... other config
}
<!-- Light-Dark theme -->
<div class="bg-white dark:bg-gray-800 text-gray-900 dark:text-white p-6">
<h2 class="text-xl font-bold">Heading</h2>
<p class="text-gray-600 dark:text-gray-300">Content that supports Dark Mode</p>
</div>
<!-- Dark Mode button -->
<button class="bg-gray-200 dark:bg-gray-700 text-gray-800 dark:text-gray-200 hover:bg-gray-300 dark:hover:bg-gray-600 px-4 py-2 rounded">
Dark Mode Button
</button>
Animation and Transition Classes
Transition Effects
<!-- Basic transitions -->
<div class="transition-colors duration-300 bg-blue-500 hover:bg-blue-600">
Smooth color change
</div>
<div class="transition-all duration-500 transform hover:scale-110 hover:rotate-3">
Change everything + rotate + scale
</div>
<!-- Specific property transitions -->
<div class="transition-opacity duration-300 opacity-50 hover:opacity-100">
Opacity change
</div>
<div class="transition-transform duration-200 hover:-translate-y-1">
Move up
</div>
Animation Classes
<!-- Basic animations -->
<div class="animate-spin w-8 h-8 border-4 border-blue-500 border-t-transparent rounded-full">
Spin forever
</div>
<div class="animate-pulse bg-gray-200 h-4 rounded">
Pulse
</div>
<div class="animate-bounce">
Bounce
</div>
<!-- Custom Animation with arbitrary values (JIT Mode) -->
<div class="animate-[fadeIn_0.5s_ease-in-out]">
Fade In Animation (requires custom @keyframes fadeIn)
</div>
Transform Classes
<!-- Scale -->
<div class="transform scale-50">Scale to 50%</div>
<div class="transform scale-110 hover:scale-125">Scale 110% and hover 125%</div>
<!-- Rotate -->
<div class="transform rotate-45">Rotate 45 degrees</div>
<div class="transform hover:rotate-180 transition-transform">Rotate on hover</div>
<!-- Translate -->
<div class="transform translate-x-4">Move right 1rem</div>
<div class="transform -translate-y-2">Move up 0.5rem</div>
<div class="transform hover:translate-x-2 hover:-translate-y-1 transition-transform">
Move right and up on hover
</div>
<!-- Skew -->
<div class="transform skew-x-12">Skew horizontally</div>
<div class="transform skew-y-6">Skew vertically</div>
Advanced Usage Techniques
1. JIT Mode and Arbitrary Values
Custom Values (JIT Mode is enabled by default)
<!-- Custom sizes and spacing -->
<div class="w-[350px]">350px width</div>
<div class="h-[calc(100vh-64px)]">Height calculated from viewport</div>
<div class="mt-[18px]">18px margin-top</div>
<!-- Custom colors -->
<div class="bg-[#bada55]">Custom background color</div>
<div class="text-[rgb(123,45,67)]">RGB text color</div>
<!-- Custom font sizes -->
<div class="text-[22px]">22px font size</div>
<div class="text-[1.375rem]">1.375rem font size</div>
<!-- Custom grid columns -->
<div class="grid-cols-[1fr_2fr_1fr]">3-column grid with fractions</div>
⚠️ Warning: Arbitrary values only work when JIT Mode is enabled
2. Using CSS Variables
<!-- CSS Variables must be defined first -->
<style>
:root {
--primary-color: #3b82f6;
--secondary-color: #64748b;
}
</style>
<div class="bg-[var(--primary-color)]">Using CSS Variable</div>
<div class="text-[var(--secondary-color)]">Text using CSS Variable</div>
3. Pseudo-elements and Pseudo-selectors
<!-- First and Last Child -->
<ul>
<li class="first:mt-0 last:mb-0 mt-4 mb-4">Item 1</li>
<li class="first:mt-0 last:mb-0 mt-4 mb-4">Item 2</li>
<li class="first:mt-0 last:mb-0 mt-4 mb-4">Item 3</li>
</ul>
<!-- Odd and Even -->
<table class="w-full">
<tbody>
<tr class="odd:bg-gray-50 even:bg-white">
<td class="px-4 py-2">Odd rows have gray background</td>
</tr>
<tr class="odd:bg-gray-50 even:bg-white">
<td class="px-4 py-2">Even rows have white background</td>
</tr>
</tbody>
</table>
<!-- Disabled State -->
<button class="bg-blue-500 text-white px-4 py-2 rounded disabled:bg-gray-300 disabled:cursor-not-allowed disabled:opacity-50"
disabled>
Disabled Button
</button>
<!-- Before and After (requires content) -->
<div class="before:content-['→'] before:mr-2 after:content-['←'] after:ml-2">
Text with symbols before and after
</div>
Common Mistakes to Avoid
1. Using Conflicting Classes
<!-- ❌ Wrong: Using conflicting classes -->
<div class="p-4 px-6 py-2">
<!-- px-6 and py-2 will override p-4 -->
<!-- Result: padding: 0.5rem 1.5rem (not 1rem all around) -->
</div>
<!-- ✅ Correct: Use specific classes -->
<div class="px-6 py-2">
<!-- Use only px and py as intended -->
</div>
2. Not Understanding Class Precedence
<!-- ❌ Problem: Later classes override earlier ones -->
<div class="text-red-500 text-blue-500">
<!-- Will be blue because text-blue-500 comes later -->
</div>
<!-- ✅ Fix: Use single class -->
<div class="text-blue-500">
<!-- Clear that it's blue -->
</div>
<!-- ✅ Or use important (avoid unless necessary) -->
<div class="!text-red-500 text-blue-500">
<!-- Will be red because of !important -->
</div>
3. Forgetting Responsive Classes
<!-- ❌ Not responsive -->
<div class="grid grid-cols-4 gap-4">
<!-- 4 columns on all screen sizes (too many for mobile) -->
</div>
<!-- ✅ Responsive -->
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4">
<!-- 1 column on mobile, 2 on tablet, 4 on desktop -->
</div>
4. Not Using Transitions
### 4. Not Using Transitions
```html
<!-- ❌ Abrupt changes -->
<button class="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded">
Abrupt button
</button>
<!-- ✅ Smooth changes -->
<button class="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded transition-colors duration-200">
Smooth button
</button>
Helpful Tools and Resources
1. Browser Extensions
Tailwind CSS DevTools
- Inspect classes being used
- Show actual CSS values
- Debug responsive breakpoints
2. VS Code Extensions
Tailwind CSS IntelliSense
// settings.json
{
"tailwindCSS.includeLanguages": {
"html": "html",
"javascript": "javascript",
"vue": "vue",
"react": "javascriptreact",
"typescript": "typescript"
},
"tailwindCSS.classAttributes": [
"class",
"className",
"classList",
"ngClass"
],
"editor.quickSuggestions": {
"strings": true
}
}
Headwind (Class Sorter)
- Sorts classes in proper order
- Makes code more readable
- Uses Tailwind's standard order
3. Online Tools
Tailwind CSS Playground
- https://play.tailwindcss.com
- Try code online
- No installation required
Tailwind UI Components
- https://tailwindui.com
- Ready-made component examples
- Learn from high-quality code
Official Documentation
- https://tailwindcss.com/docs
- Comprehensive documentation
- Examples for every class
Hands-On Project: Create a Feature Card
Let's create a component that covers many techniques learned in EP 2:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Feature Card Example</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gray-50 p-8">
<div class="max-w-md mx-auto">
<!-- Feature Card -->
<div class="group bg-white rounded-2xl shadow-lg hover:shadow-xl transition-all duration-300 overflow-hidden border border-gray-100">
<!-- Header Image -->
<div class="relative h-48 bg-gradient-to-br from-blue-500 to-purple-600 overflow-hidden">
<div class="absolute inset-0 bg-black bg-opacity-20 group-hover:bg-opacity-10 transition-all duration-300"></div>
<div class="relative h-full flex items-center justify-center">
<div class="w-16 h-16 bg-white bg-opacity-20 rounded-2xl flex items-center justify-center group-hover:scale-110 transition-transform duration-300">
<svg class="w-8 h-8 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z" />
</svg>
</div>
</div>
</div>
<!-- Content -->
<div class="p-6">
<div class="flex items-center justify-between mb-3">
<span class="inline-block bg-blue-100 text-blue-800 text-xs font-semibold px-2.5 py-0.5 rounded-full">
Technology
</span>
<span class="text-sm text-gray-500">2 min read</span>
</div>
<h3 class="text-xl font-bold text-gray-900 mb-2 group-hover:text-blue-600 transition-colors duration-200">
Maximum Performance
</h3>
<p class="text-gray-600 text-sm leading-relaxed mb-4">
Boost your website's speed and performance with modern techniques. Support for all devices included.
</p>
<!-- Stats -->
<div class="flex items-center justify-between mb-4 p-3 bg-gray-50 rounded-lg">
<div class="text-center">
<div class="text-lg font-bold text-gray-900">99%</div>
<div class="text-xs text-gray-500">Uptime</div>
</div>
<div class="text-center">
<div class="text-lg font-bold text-gray-900">< 1s</div>
<div class="text-xs text-gray-500">Loading</div>
</div>
<div class="text-center">
<div class="text-lg font-bold text-gray-900">A+</div>
<div class="text-xs text-gray-500">Security</div>
</div>
</div>
<!-- Action Buttons -->
<div class="flex gap-2">
<button class="flex-1 bg-blue-500 hover:bg-blue-600 text-white font-medium py-2 px-4 rounded-lg transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2">
Learn More
</button>
<button class="p-2 text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-lg transition-all duration-200">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z" />
</svg>
</button>
</div>
</div>
<!-- Footer -->
<div class="px-6 py-3 bg-gray-50 border-t border-gray-100">
<div class="flex items-center justify-between">
<div class="flex items-center space-x-2">
<div class="w-6 h-6 bg-blue-500 rounded-full flex items-center justify-center">
<span class="text-xs font-bold text-white">T</span>
</div>
<span class="text-sm text-gray-600">By Team Tailwind</span>
</div>
<span class="text-xs text-gray-400">Updated 2h ago</span>
</div>
</div>
</div>
</div>
</body>
</html>
Summary
In EP 2, we learned about the core concepts that make Tailwind CSS different from other CSS frameworks:
Key Learnings:
- Utility-First means using small, single-purpose classes to compose designs instead of writing separate CSS files
- Class categorization system covering Layout, Spacing, Colors, Typography, and more
- Expert memorization techniques using patterns and creating personal systems
- Responsive Design made easy with the breakpoint system
- State Variants for Hover, Focus, and various states
- Animation and Transitions that bring websites to life
- JIT Mode and arbitrary values for unlimited flexibility
Important Points to Remember:
- Mobile-First: Start from mobile and expand to desktop
- Later classes win: When classes conflict, the later one takes precedence
- Use Transitions: Make changes smooth and polished
- JIT Mode: Use arbitrary values without limits
- Dark Mode: Must be enabled in config first
EP 3 "Mastering Colors and Fonts: Create Design Systems with Tailwind" will cover professional color and typography techniques, creating consistent design systems, and customizing Tailwind to match your brand.
Ready to become a Tailwind CSS pro? Follow Superdev School to not miss the amazing techniques in the next episode!
Let's build beautiful websites with Tailwind CSS! 🚀
Read more
🔵 Facebook: Superdev School (Superdev)
📸 Instagram: superdevschool
🎬 TikTok: superdevschool
🌐 Website: www.superdev.school