Course contentsShow
← React
Lesson 1918 of 2,39644. Styling ApproachesFree lesson

Customizing the Tailwind Config

Extending theme values (colors, spacing, fonts) in tailwind.config.js to match your design system.

Customizing the Tailwind Config

What you'll learn: How to extend Tailwind's default theme with custom colors, spacing, and fonts that match your design system.

Why Customize the Config?

Out of the box, Tailwind provides sensible defaults: colors like blue-500, spacing values like p-4, and font families like font-sans. But your brand has specific colors, your design system uses a custom spacing scale, or you need particular fonts. Rather than fighting Tailwind with arbitrary values everywhere (text-[#FF6B35]), you extend the config once and get clean, semantic utilities.

Extending Theme Values

Open tailwind.config.js and use the theme.extend object to add your custom values without replacing Tailwind's defaults:

/** @type {import('tailwindcss').Config} */
export default {
  content: ['./index.html', './src/**/*.{js,jsx}'],
  theme: {
    extend: {
      colors: {
        brand: {
          primary: '#FF6B35',
          secondary: '#004E89',
          accent: '#F7B801',
        },
      },
      spacing: {
        '128': '32rem',
        '144': '36rem',
      },
      fontFamily: {
        display: ['Poppins', 'sans-serif'],
        body: ['Inter', 'sans-serif'],
      },
    },
  },
  plugins: [],
}

Now you can use bg-brand-primary, mt-128, or font-display in your JSX—clean, semantic, and consistent.

Think of It Like Variables

Customizing the config is like defining CSS variables or constants, but Tailwind generates all the related utilities automatically (hover states, responsive variants, etc.). You define the values once; Tailwind creates text-brand-primary, border-brand-primary, bg-brand-primary/50, and more.

Key Takeaway: Extend tailwind.config.js with your design system's colors, spacing, and fonts to create semantic, reusable utilities that keep your markup clean and your brand consistent.