Course contentsShow
← Web Development
Lesson 644 of 2,98211. Utility-First CSS with TailwindFree lesson

Extending the Default Theme

Learn how to extend Tailwind's default theme with custom colors, spacing, and design tokens in tailwind.config.js.

Extending the Default Theme

You'll learn how to add your own design tokens to Tailwind CSS without losing the built-in utilities.

What This Means

Tailwind comes with hundreds of default utility classes for colors, spacing, fonts, and more. But what if your brand uses a specific shade of blue that isn't in Tailwind's palette? Or you need a custom spacing value? Extending the theme lets you add your own values while keeping all of Tailwind's defaults intact.

Think of it like adding new spices to your kitchen cabinet—you're not throwing out the basics, just expanding your options.

How It Works

In your tailwind.config.js file, you use the extend property inside theme:

module.exports = {
  theme: {
    extend: {
      colors: {
        'brand-blue': '#0066CC',
        'brand-orange': '#FF6B35',
      },
      spacing: {
        '128': '32rem',
        '144': '36rem',
      },
    },
  },
}

Now you can use classes like bg-brand-blue, text-brand-orange, mt-128, or p-144 alongside all the standard Tailwind utilities. The key word is extend—you're adding to the defaults, not replacing them.

Why Use Extend?

Without extend, if you define colors directly under theme, you'd overwrite all of Tailwind's color utilities. You'd lose bg-blue-500, text-red-600, and everything else. By using extend, you preserve the full default palette while adding your custom tokens.

This approach keeps your design system flexible and ensures you don't accidentally break existing utilities.

Key Takeaway: Use theme.extend in your config file to add custom design tokens like colors and spacing while preserving all of Tailwind's default utilities.