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

Customizing Colors

Define custom color palettes and override default colors in the theme configuration.

Customizing Colors

You'll learn how to define your own color palette in Tailwind and replace the default colors to match your brand.

What Problem Does This Solve?

Tailwind ships with a comprehensive default color palette (blue-500, gray-300, etc.), but your project likely has specific brand colors. Instead of fighting against the defaults or adding one-off utilities, you can customize the entire color system in your tailwind.config.js file.

How Color Customization Works

In the theme section of your configuration file, you have two approaches:

Overriding completely — Replace all default colors:

module.exports = {
  theme: {
    colors: {
      primary: '#5B21B6',
      secondary: '#F59E0B',
      white: '#ffffff',
    }
  }
}

Now only bg-primary, text-secondary, and bg-white exist. All default colors are gone.

Extending selectively — Keep defaults but add custom colors:

module.exports = {
  theme: {
    extend: {
      colors: {
        brand: '#5B21B6',
        accent: '#F59E0B',
      }
    }
  }
}

Now you have bg-brand and text-accent plus all the default Tailwind colors.

Think of It Like Paint Swatches

Imagine Tailwind gives you a paint store's standard color cards. Customizing colors is like telling the store: "I only want these specific paint samples on my wall" (override) or "Add my custom colors to your existing selection" (extend).

Key Takeaway: Customize colors in tailwind.config.js by either replacing the entire colors object to match your brand exactly, or using extend.colors to add custom colors while keeping Tailwind's defaults.