When building a website, one of the fundamental decisions you’ll face is how to handle your CSS. Should you rely on a utility-first framework like Tailwind CSS, or write custom CSS from scratch? Each approach has its strengths and trade-offs, and the right choice depends on your project’s requirements, developer preferences, and future scalability.
In this blog, we will explore both Tailwind and custom CSS, diving into what makes them unique, their benefits, and when to choose one over the other. By the end, you'll have a clearer understanding of which method best suits your next project.
Let’s get started.
What is Tailwind CSS?
Tailwind is a utility-first CSS framework that provides low-level utility classes to help you style your elements directly in your HTML. Unlike traditional CSS frameworks that come with predefined components (like Bootstrap), Tailwind allows you to build custom designs by combining utility classes without writing any actual CSS.
For example:
<div class="bg-blue-500 text-white p-4 rounded-lg">
This is a Tailwind-styled div
</div>
Instead of creating custom class names and writing CSS rules for them, you use pre-built utility classes like bg-blue-500
for background color, text-white
for text color, p-4
for padding, and so on.
What is Custom CSS?
Custom CSS refers to writing your own styles from scratch. This involves defining your class names and assigning CSS properties and values to control the appearance of elements. You have complete freedom over how you write your styles, including organizing them into reusable components or creating a design system tailored to your needs.
Here’s an example:
<div class="custom-div">
This is a custom CSS styled div
</div>
<style>
.custom-div {
background-color: #3490dc;
color: white;
padding: 16px;
border-radius: 10px;
}
</style>
In this case, you define a custom class (custom-div) and manually apply your CSS properties in a <style>
block or an external stylesheet.
Tailwind CSS: Pros and Cons
Pros:
Rapid Development: Tailwind speeds up the development process by allowing you to apply styles directly in your HTML. No need to switch between your CSS and HTML files constantly.
Responsive by Design: With built-in responsive utilities like
sm:
,md:
, andlg:
, Tailwind makes it easier to apply breakpoints and design for different devices.No Naming Conflicts: Since Tailwind relies on utility classes, you don't have to worry about creating conflicting class names, which is a common issue when working with custom CSS.
Consistency: The use of predefined utility classes enforces a consistent design system throughout your project, making it easier to maintain the codebase.
Cons:
HTML Bloat: Styling everything in your HTML can lead to a bloated codebase, with long class strings that may reduce readability.
Learning Curve: While Tailwind is powerful, there’s a learning curve involved, especially if you’re used to traditional CSS methods.
Customization Limits: Although Tailwind offers great flexibility, some developers find that it limits creativity, as you're constrained by its pre-built utilities unless you extend the framework.
Custom CSS: Pros and Cons
Pros:
Full Control: With custom CSS, you have complete control over your styles, making it easier to implement highly specific designs that may not be achievable with a utility-first framework.
Cleaner HTML: Custom CSS allows you to keep your HTML clean and uncluttered, focusing purely on structure while your styles are defined separately.
Scalability: If organized well, custom CSS can scale efficiently with large projects. By building reusable classes and components, you can create a robust design system that adapts to future needs.
Cons:
Slower Development: Writing custom CSS can take longer than using a utility-first framework, especially for common styling patterns that Tailwind handles out of the box.
Potential for Inconsistency: Without a predefined design system, it's easy for custom CSS to become inconsistent across pages, especially when working in a team or on a large project.
Maintenance: Over time, managing a growing custom CSS codebase can become challenging, especially if not well-organized. Naming conflicts and specificity issues may arise.
Tailwind or Custom CSS: Which Should You Choose?
Both Tailwind and custom CSS have their advantages, but your choice will depend on a few factors:
- Project Size:
If you're building a smaller project and need to move fast, Tailwind CSS might be the better option. Its utility-first approach allows for rapid development without the need to set up a comprehensive design system.
For larger projects where scalability and long-term maintainability are key, custom CSS provides more control and can be tailored to the project's needs.
- Developer Experience:
Developers who prefer working with pre-built systems and want to focus on functionality rather than design details may find Tailwind CSS more convenient.
On the other hand, if you enjoy fine-tuning every aspect of your design, custom CSS gives you the freedom to do so without being constrained by a framework.
- Consistency vs. Flexibility:
Tailwind CSS excels at enforcing a consistent design system across your project, which can be a huge advantage for teams.
Custom CSS offers greater flexibility, which is ideal if your design needs deviate significantly from typical patterns or if you want a highly unique look.
Conclusion
Ultimately, the choice between Tailwind and custom CSS depends on your project’s needs and your personal workflow preferences. Tailwind CSS is perfect for developers who want to speed up their development process and maintain a consistent design system, while custom CSS is ideal for those who want more control over their design and are willing to spend extra time fine-tuning their styles.
Also, no matter what you choose, Dualite is here to help in both scenarios. Dualite supports both Tailwind CSS and custom CSS, allowing you to choose whichever fits your needs best.
Top comments (13)
My favorite setup is:
<script src="https://cdn.tailwindcss.com"></script>
This one turn any HTML page to tailwind capable, and I can use it without any CSS need.
Which is also means I can focus on HTML DOM structure. In my opinion is the Tailwind greatest strength is the simple layout structure declaration.
for example:
each parragraph have common distance between, and easy to read.
at the end
Of course, when whole POC work with Tailwind are done, and we are getting the border of capability then good to use some custom CSS well. Can live fine together.
Ok, but it's adding the entire Tailwind script, and if you're using something like Angular, it's better to add the package directly. Tailwind will then include only the utility classes you're actually using.
Custom CSS, all the life, the rest is bla bla bla bla
Vanilla css for complex styling
Tailwind for fast development
It really depends on the project and the team's choice, but from my perspective, writing custom CSS is becoming less common lately. Many teams now prefer Tailwind or similar frameworks because they speed up development and help maintain consistency. However, it’s still important to choose what works best for your project.
Tailwind for sure.
I've worked on both and tailwind is easier to maintain + improve.
Idk man, but writing custom css is bloated, indeed Tailwind clutters html and there's a solution for it, use @apply directive in css file and use that class names to html
And for your wrong assumption that it has less pre built things, it's the reason that tailwinds is very fast, and if needed extra things then have to extend but a small solution is that using arbitrary css value classes, and other solution is to use custom css with tailwind.
I don't know about maintainability of custom CSS. It gets bloated a lot to the point the next developer who works on it later on will have hard time coping and figuring out some css class names. Meanwhile tailwind with prettier is pretty straightforward. There's no hidden styles. Unless you're using Svelte or writing every little things to be a component, there's really no benefit custom CSS has over tailwind considering most projects just extend and limit to the project specific styles.
Also if you're wonder why your React app is slow. Probably because you write everything as a function and even styles are a component which needs to be executed in a VDOM to calculate the diff irrespective of its on server or client. At that point, just use SvelteKit which atleast optimize with a compile step.
At this point, I'm not fighting anymore. I'll write CSS whenever I need to. And in the other cases I'll use a based LLM like Claude 3.5 to generate the Tailwind for me.
Asking ChatGpt and copy pasting the answer here is common now. 🙄
That being said..
Pure CSS ? No.
Pre-processor / SCSS? Yes.
Tailwind? Only after having mastered CSS / SCSS
I prefer Tailwind for speed and ease, even if I need to make some design where Tailwind is inflexible I use Custom CSS, maintaining a clear and consistent architecture.