LEGACY Tailwind CSS v3-era example, archived unchanged. Kept for reference only — it uses the v3 Play CDN and JS config, both removed in v4. Current documentation →

Tailwind CSS Colors

Master the art of creating beautiful and vibrant interfaces with Tailwind's comprehensive color system

What are Tailwind CSS Colors?

Colors in Tailwind CSS provide a carefully curated palette that creates beautiful, accessible, and consistent designs. They're essential for creating visual hierarchies, conveying meaning, and establishing brand identity in your UI.

Tailwind makes it easy to apply colors to text, backgrounds, borders, and other UI elements with simple utility classes. This allows for rapid prototyping and consistent design across your project.

Complete Tailwind Color Palette

Gray Scales

gray-50
gray-100
gray-200
gray-300
gray-400
gray-500
gray-600
gray-700
gray-800
gray-900

Interactive Color Playground

0% 50% 100%

Preview

Tailwind CSS Class:

bg-indigo-600

Common Color Combinations

Primary/Secondary

bg-indigo-600 bg-purple-500

Success/Error

bg-green-500 bg-red-500

Neutral Palette

bg-gray-100 to bg-gray-700

Color Accessibility

Ensuring your color choices are accessible to all users is essential. Here are some key considerations when working with colors in Tailwind CSS:

Contrast Ratio

Maintain a minimum contrast ratio of 4.5:1 for normal text and 3:1 for large text to ensure readability.

Good ✓
text-white on bg-indigo-700
Good ✓
text-indigo-800 on bg-indigo-300

Avoid Problematic Combinations

Certain color combinations can be difficult for people with color vision deficiencies.

Avoid ✗
Red on green (colorblind issues)
Avoid ✗
Low contrast combination

Pro Tip

Use Tailwind's built-in color shades to your advantage. Darker shades (700-900) generally work well with white text, while lighter shades (50-300) work better with dark text.

Always test your color combinations with accessibility tools like WebAIM's Contrast Checker or the built-in accessibility tools in your browser's developer tools.

Customizing Colors

Tailwind makes it easy to customize the default color palette to match your brand or design requirements. Here's how to add custom colors to your Tailwind project:

Via tailwind.config.js

tailwind.config.js
module.exports = { theme: { extend: { colors: { 'brand': { light: '#c7d2fe', // indigo-200 DEFAULT: '#4f46e5', // indigo-600 dark: '#3730a3', // indigo-800 }, 'accent': '#f472b6', // pink-500 }, }, }, }

This adds custom colors that can be used with Tailwind's utility classes like bg-brand, text-brand-light, or border-accent.

Using Arbitrary Values

HTML
<div class="bg-[#1a5fb4] text-white p-4 rounded"> Custom hex color </div> <p class="text-[rgb(22,163,74)] font-bold"> RGB color value </p> <button class="border-2 border-[#f59e0b] px-4 py-2 rounded"> Custom border color </button>

You can use arbitrary values directly in your HTML for one-off custom colors without modifying your Tailwind configuration.

Best Practices

  • For brand consistency, define your custom colors in your Tailwind configuration rather than using arbitrary values throughout your code.
  • Use a color system with clear naming conventions that reflect their purpose (e.g., primary, secondary, danger) rather than their visual appearance.
  • Consider adding multiple shades of your brand colors for different use cases (e.g., hover states, backgrounds, text).
  • Be mindful of file size—only extend the colors you need rather than adding unnecessary options.

Ready to Master Tailwind Colors?

Colors are a fundamental aspect of any design system. With Tailwind CSS, you have a powerful and flexible color system at your fingertips that allows you to create beautiful, accessible, and consistent designs with minimal effort.

slate-400
slate-500
slate-600
slate-700
slate-800
slate-900
zinc-50
zinc-100
zinc-200
zinc-300
zinc-400
zinc-500
zinc-600
zinc-700
zinc-800
zinc-900

Primary Colors

Red

red-50
red-100
red-200
red-300
red-400
red-500
red-600
red-700
red-800
red-900

Blue

blue-50
blue-100
blue-200
blue-300
blue-400
blue-500
blue-600
blue-700
blue-800
blue-900

Green

green-50
green-100
green-200
green-300
green-400
green-500
green-600
green-700
green-800
green-900

Special Shades

Indigo

indigo-50
indigo-100
indigo-200
indigo-300
indigo-400
indigo-500
indigo-600
indigo-700
indigo-800
indigo-900

Purple

purple-50
purple-100
purple-200
purple-300
purple-400
purple-500
purple-600
purple-700
purple-800
purple-900

Emerald

emerald-50
emerald-100
emerald-200
emerald-300
emerald-400
emerald-500
emerald-600
emerald-700
emerald-800
emerald-900

Using Color Classes

Apply colors using this pattern: {property}-{color}-{shade}

Examples: text-blue-500, bg-red-700, border-green-300

Color Implementation Methods

Text Colors

Text colors are applied using the text-{color}-{shade} utility classes:

Tailwind is awesome

Tailwind is awesome

Tailwind is awesome

Tailwind is awesome

Tailwind is awesome

Tailwind is awesome

Tailwind is awesome

Tailwind is awesome

Tailwind is awesome

Tailwind is awesome

Tailwind is awesome

Use cases:

  • Creating visual hierarchy with different text importance levels
  • Matching brand colors in textual content
  • Improving readability against different backgrounds

Background Colors

Background colors use the bg-{color}-{shade} pattern:

Tailwind is awesome

Tailwind is awesome

Tailwind is awesome

Use cases:

  • Creating contrasting sections on a page
  • Highlighting important UI elements
  • Implementing color-coded categories or statuses
  • Creating cards, panels, or content containers

Text Decoration Colors

You can style underlined text with colors different from the text itself:

Tailwind is awesome

Tailwind is awesome

Use cases:

  • Creating stylish link hover states
  • Emphasizing important text while maintaining a cohesive color scheme
  • Creating visual separators within text blocks

Border Colors

Border colors are specified using border-{color}-{shade} after defining border width:

Use cases:

  • Form input validation states (red for errors, green for success)
  • Creating visual boundaries between UI sections
  • Highlighting interactive elements
  • Creating color-coded containers

Divide Colors

When using the divide utility to add separators between elements, you can specify colors:

Item 1
Item 2
Item 4
Item 5
Item 6

Use cases:

  • Creating subtle separation in lists or content sections
  • Implementing visually consistent dividers in navigation menus
  • Styling table rows with colored separators

Outline Colors

Add colored outlines to elements using outline outline-{color}-{shade}:

Use cases:

  • Creating focus states for accessibility
  • Secondary or tertiary button styles
  • Highlighting active UI elements

Box Shadow Colors

Add colored shadows with opacity control:

Use cases:

  • Creating depth and elevation in UI
  • Drawing attention to important call-to-action buttons
  • Implementing card hover effects
  • Creating "glow" effects for special elements

Accent Colors

Customize the color of UI controls like checkboxes and radio buttons:

Option 1
Option 2
Option 3

Use cases:

  • Matching form controls to your brand colors
  • Creating visually consistent form experiences
  • Implementing feature toggles with meaningful colors

Arbitrary Colors

When you need specific colors outside the default palette:

Hello
Hello
Hello

Use cases:

  • Implementing exact brand colors not in the default palette
  • Creating gradient or specialized color schemes
  • Matching legacy design systems

Best Practices

Color Consistency

  • Use the same shade numbers across your project
  • Maintain consistent color meaning (red for errors, green for success)
  • Define a color palette for your brand and stick to it

Accessibility

  • Ensure sufficient contrast between text and background
  • Test colors with accessibility tools
  • Consider color blindness when designing your interface

Pro Tip

For complex projects, extract common colors into the Tailwind config. This makes your codebase more maintainable and ensures color consistency.

Advanced Techniques

Color Opacity

Most color utilities can have opacity modifiers:

75% opacity blue background
<div class="bg-blue-500/75">75% opacity blue background</div>

Responsive Color Variations

Colors can change based on screen size:

Blue on mobile, green on medium screens and up
<div class="text-blue-500 md:text-green-500">Blue on mobile, green on medium screens and up</div>

Hover, Focus, and Other States

Apply colors on various states:

<button class="bg-blue-500 hover:bg-blue-700">Button with hover state</button>

CSS Colors Quick Reference

Color Classes Reference

Text Classes

  • text-{color}-{shade} - Sets text color
  • text-opacity-{value} - Sets text opacity
  • text-{hex} - Sets arbitrary text color

Background Classes

  • bg-{color}-{shade} - Sets background color
  • bg-opacity-{value} - Sets background opacity
  • bg-gradient-to-{direction} - Creates gradient

Border Classes

  • border-{color}-{shade} - Sets border color
  • border-opacity-{value} - Sets border opacity
  • border-{side}-{color}-{shade} - Side-specific color

Other Color Utilities

  • ring-{color}-{shade} - Sets focus ring color
  • shadow-{color}-{shade} - Sets shadow color
  • accent-{color}-{shade} - Sets accent color

Color Showcase

This showcase displays Tailwind's primary colors in various shade intensities:

Blue

Red

Green

Purple

Implementation Examples

Text Colors

This is blue text (500)

This is red text (600)

This is green text (700)

This is purple text (800)

<p class="text-blue-500">This is blue text</p>
<p class="text-red-600">This is red text</p>

Background Colors

Blue background (500)
Red background (600)
Green background (700)
Purple background (800)
<div class="bg-blue-500 text-white">Blue background</div>
<div class="bg-red-600 text-white">Red background</div>

Summary & Conclusion

Key Advantages

  • Comprehensive color system with carefully selected palette
  • Consistent naming convention for easy memorization
  • Multiple shades (50-900) for design flexibility
  • Works with various HTML elements and properties

Common Uses

  • Creating visual hierarchy with text colors
  • Adding engaging backgrounds to UI components
  • Establishing visual boundaries with borders
  • Creating depth with shadows and outlines

Accessibility Best Practices

  • Maintain a minimum contrast ratio of 4.5:1 between text and background
  • Test your color combinations with accessibility tools
  • Provide alternative visual cues beyond just color for important information
  • Consider color blindness when choosing your palette

Color Customization

For projects requiring custom colors beyond the default palette, you can extend Tailwind's configuration:

// tailwind.config.js
module.exports = {
  theme: {
    extend: {
      colors: {
        'brand-blue': '#1992d4',
        'brand-purple': '#9061f9',
      }
    }
  }
}

This allows you to use classes like bg-brand-blue throughout your project.

Tailwind's color system provides a powerful and flexible way to implement consistent colors across your project. By understanding the various color utilities and their applications, you can create visually cohesive and accessible interfaces while maintaining development efficiency. The ability to combine color utilities with responsive and state variants makes Tailwind CSS an excellent choice for building modern, adaptable user interfaces.