Migrating from traditional CSS to Tailwind CSS? Here's the property-by-property guide.
Core Property Mappings
Layout
| CSS | Tailwind |
|---|---|
display: flex |
flex |
display: grid |
grid |
display: none |
hidden |
display: block |
block |
display: inline-flex |
inline-flex |
position: relative |
relative |
position: absolute |
absolute |
position: fixed |
fixed |
position: sticky |
sticky |
Spacing (4px base unit)
| CSS | Tailwind |
|---|---|
padding: 4px |
p-1 |
padding: 8px |
p-2 |
padding: 16px |
p-4 |
padding: 24px |
p-6 |
margin: 0 auto |
mx-auto |
gap: 16px |
gap-4 |
Sizing
| CSS | Tailwind |
|---|---|
width: 100% |
w-full |
height: 100vh |
h-screen |
max-width: 640px |
max-w-xl |
min-height: 0 |
min-h-0 |
Responsive Design
The biggest win with Tailwind is inline responsive design:
/* Traditional CSS */
.container {
font-size: 14px;
padding: 8px;
}
@media (min-width: 768px) {
.container {
font-size: 16px;
padding: 16px;
}
}
@media (min-width: 1024px) {
.container {
font-size: 18px;
padding: 24px;
}
}
<!-- Tailwind: all in one line -->
<div class="text-sm p-2 md:text-base md:p-4 lg:text-lg lg:p-6">
Tailwind breakpoints: sm (640px), md (768px), lg (1024px), xl (1280px), 2xl (1536px).
Flexbox Translation
.row {
display: flex;
justify-content: space-between;
align-items: center;
gap: 16px;
}
<div class="flex justify-between items-center gap-4">
Grid Translation
.grid-3 {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 24px;
}
<div class="grid grid-cols-3 gap-6">
Responsive grid:
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
Colors
Tailwind uses a numeric scale (50â950):
<p class="text-gray-700 bg-blue-50 border border-blue-200">
<span class="text-red-500">Error</span>
</p>
Custom colors with arbitrary values:
<div class="bg-[#1a73e8] text-[#ffffff]">
Dark Mode
/* Traditional */
body { background: white; color: black; }
@media (prefers-color-scheme: dark) {
body { background: #1a1a1a; color: white; }
}
<!-- Tailwind: dark: prefix -->
<body class="bg-white text-black dark:bg-gray-900 dark:text-white">
When NOT to Use Tailwind
- Complex multi-step keyframe animations
- Highly dynamic runtime styles (JavaScript-driven values)
- Third-party component overrides
- Email HTML (inline styles required)
- Very large legacy codebases (high migration risk)
Gradual Migration Strategy
Don't rewrite everything at once. For existing projects:
- Install Tailwind alongside existing CSS
- Convert leaf components first (buttons, badges, inputs)
- Move up to layout components
- Delete old CSS when a component is fully converted
- Run
git diff --statto measure CSS reduction
Automate the Mechanical Parts
For the repetitive property-to-class mapping, use DevToolBox's CSS to Tailwind converter to handle the mechanical translation. Paste CSS, get Tailwind classes.
Try the free CSS to Tailwind converter â paste CSS, get Tailwind classes instantly.
Top comments (1)
I am just migrating from Tailwind to plain CSS, because the Tailwind is AI generated - like 40 parameters per DIV - total chaos, unsustainable shitshow