tailwindcss
A utility-first CSS framework that provides low-level classes to build custom designs without writing custom CSS.
Core Concepts
-
Utility Classes:
Small, single-purpose classes liketext-center
,bg-blue-500
,p-4
, etc.<div class="bg-gray-200 p-4 text-center">Hello, Tailwind!</div>
-
Responsive Design:
Use breakpoints likesm
,md
,lg
,xl
,2xl
for responsive styling.<div class="text-sm md:text-lg lg:text-xl">Responsive Text</div>
-
Customization:
Easily customize colors, spacing, etc., throughtailwind.config.js
. -
State Variants:
Apply styles on hover, focus, etc.<button class="bg-blue-500 hover:bg-blue-700 text-white">Hover Me</button>
-
Dark Mode:
Usedark:
prefix for dark mode styles.<div class="bg-white dark:bg-gray-800 text-black dark:text-white">
Dark Mode
</div>
Common Utility Classes
- Spacing:
p-4
,m-2
,px-6
,py-3
- Colors:
text-red-500
,bg-green-200
- Typography:
text-xl
,font-bold
,uppercase
- Flexbox/Grid:
flex
,grid
,justify-center
,items-center
- Borders:
border
,border-2
,rounded-lg
- Shadows:
shadow-md
,shadow-lg
tip
- Use the JIT Mode (Just-In-Time Compiler) for faster builds and smaller output.
- Install Tailwind Plugins for forms, typography, or aspect ratios to extend features.
- Play with Tailwind’s Playground: Try out Tailwind Play.