Up until now, we’ve been using Tailwind’s default styles — default colors, spacing scale, fonts, and layout sizing. But real projects usually need brand identity, like:
That’s where tailwind.config.js comes in.
This file allows you to extend Tailwind and build your own UI style system, while still using Tailwind utilities.
| Feature | Purpose |
|---|---|
npx tailwindcss init | Generate config file |
theme.extend | Add custom design values |
| Custom colors | Create your brand palette |
| Custom fonts | Use Google Fonts or local fonts |
| Custom container settings | Center and set page width |
If your project doesn’t have it yet, run:
npx tailwindcss init
This generates:
// tailwind.config.jsmodule.exports = {theme: {extend: {},},plugins: [],}
This is where we customize Tailwind.
Let’s say your brand color is a shade of purple (#6366F1).
Add it under theme.extend.colors:
module.exports = {theme: {extend: {colors: {brand: "#6366F1",},},},};
Now you can use it everywhere:
<button class="bg-brand text-white px-4 py-2 rounded">Brand Button</button>
💡 No need to remember hex codes ever again.
Example — using Inter from Google Fonts:
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap');
extend: {fontFamily: {sans: ["Inter", "sans-serif"],},},
<h1 class="font-sans text-3xl font-bold">Hello Tailwind</h1>
Smooth and consistent typography ✅
Tailwind has a container utility, and we can set its max width and center behavior:
extend: {container: {center: true,padding: "1.5rem",},},
Usage:
<div class="container"><h1 class="text-2xl font-bold">Centered Layout</h1></div>
This ensures your website layout stays neat and aligned.
Once we’ve added custom fonts and colors:
<div class="max-w-sm mx-auto p-6 bg-white rounded-xl shadow-md text-center font-sans"><h2 class="text-2xl font-bold text-brand mb-2">Tailwind Custom Branding</h2><p class="text-gray-600 mb-4">Tailwind makes it easy to build your own design system.</p><button class="bg-brand hover:bg-brand/90 text-white px-4 py-2 rounded-lg transition duration-300">Learn More</button></div>
This component now has your brand identity — not just Tailwind defaults.
| Customization | Where | Result |
|---|---|---|
| Custom colors | theme.extend.colors | Consistent brand palette |
| Custom fonts | theme.extend.fontFamily | Unified typography |
| Container settings | theme.extend.container | Clean page layout |
Everything under extend | Avoids overriding core theme | Safe scaling |
By customizing Tailwind properly, you create a maintainable design system that scales across your project.