Menu

1 / 2

Learning TailwindCSS As If You Built It Yourself

DEV Community·Mohamed Idris·6 months ago
#4RjH5q7K
#decision#css#tailwindcss#learning#class
Reading 0:00
15s threshold

If you have ever opened a year old CSS file and tried to figure out which class does what, you remember the feeling. card-2 , card-2-blue , card-2-blue-mobile , card-2-blue-mobile-final , all in different files, all targeting the same component, all "almost" doing the same thing. Renaming any of them is risky. Deleting any of them is scarier. So nobody does, and the file grows forever.

That graveyard of dead classes is what Tailwind was invented to prevent.

What is TailwindCSS, really

Think of Tailwind as a tool belt of pre cut Lego bricks for styling . Instead of inventing class names like card-header-title-medium-blue and writing CSS for them, you snap together a handful of small, single purpose classes right in your HTML:

<div class= "rounded-lg bg-white p-6 shadow" > <h2 class= "text-xl font-semibold text-slate-900" > Mochi </h2> <p class= "mt-2 text-slate-600" > A small white cat with big plans. </p> </div>

Enter fullscreen mode

Exit fullscreen mode

Each class does exactly one thing.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.