A color system helps keep your website looking nice and easy to use. It makes sure colors match well and stay consistent everywhere.
0
0
Why a color system matters in Tailwind
Introduction
When designing a website to make sure all buttons and text use the same colors.
When you want your brand colors to look the same on every page.
When working with a team so everyone uses the same color rules.
When you want to quickly change colors across the whole site without fixing each part.
When making sure your site is easy to read and looks good on all devices.
Syntax
Tailwind
module.exports = {
theme: {
extend: {
colors: {
primary: '#1D4ED8',
secondary: '#9333EA',
accent: '#F59E0B'
}
}
}
}This is how you add custom colors in Tailwind's config file.
Use simple names like primary or accent to keep colors clear.
Examples
Use the primary color as background and white text for good contrast.
Tailwind
bg-primary text-white
Text uses secondary color normally, changes to accent color when hovered.
Tailwind
text-secondary hover:text-accent
Add a border using the primary color to highlight elements.
Tailwind
border border-primary
Sample Program
This page uses a color system with primary, secondary, and accent colors. The background is primary blue, the button is purple (secondary), and it changes to orange (accent) when hovered.
Tailwind
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>Color System Example</title> <script src="https://cdn.tailwindcss.com"></script> <script> tailwind.config = { theme: { extend: { colors: { primary: '#1D4ED8', secondary: '#9333EA', accent: '#F59E0B' } } } }; </script> </head> <body class="bg-primary text-white min-h-screen flex flex-col items-center justify-center"> <h1 class="text-4xl font-bold mb-4">Welcome to My Site</h1> <button class="bg-secondary hover:bg-accent text-white font-semibold py-2 px-4 rounded"> Click Me </button> </body> </html>
OutputSuccess
Important Notes
Using a color system helps keep your site consistent and easier to update.
Choose colors that have good contrast for readability and accessibility.
Tailwind makes it easy to define and use custom colors everywhere.
Summary
A color system keeps your website looking neat and consistent.
It helps teams use the same colors and makes updates simple.
Tailwind lets you easily add and use custom colors in your design.