A color system helps keep your website looking nice and easy to use. It makes sure colors match well and stay consistent everywhere.
Why a color system matters in Tailwind
Start learning this pattern below
Jump into concepts and practice - no test required
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.
bg-primary text-white
text-secondary hover:text-accent
border border-primary
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.
<!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>
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.
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.
Practice
Solution
Step 1: Understand the purpose of a color system
A color system helps keep colors consistent across a website, so everything looks neat and professional.Step 2: Connect to Tailwind usage
Tailwind allows easy use of custom colors, making updates simple and consistent for teams.Final Answer:
It keeps the website colors consistent and easy to update. -> Option CQuick Check:
Color system = consistency and easy updates [OK]
- Confusing color system with performance improvements
- Thinking it creates animations automatically
- Believing it removes HTML tags
brand-blue in the configuration?Solution
Step 1: Check correct JSON syntax for Tailwind config
Keys must be strings in quotes, and color values must be strings in quotes.Step 2: Identify the correct option
"colors": { 'brand-blue': '#1DA1F2' } uses quotes correctly around both key and value, making it valid.Final Answer:
"colors": { 'brand-blue': '#1DA1F2' } -> Option AQuick Check:
Proper quotes around keys and values = "colors": { 'brand-blue': '#1DA1F2' } [OK]
- Omitting quotes around color hex code
- Using unquoted keys in JSON
- Using wrong quote types inconsistently
{
theme: {
extend: {
colors: {
'brand-green': '#10B981'
}
}
}
}What color will the class
bg-brand-green apply?Solution
Step 1: Understand the config extension
The config adds a new color named 'brand-green' with hex #10B981.Step 2: Match class to color
The classbg-brand-greenuses this custom color as background.Final Answer:
A shade of green (#10B981) -> Option BQuick Check:
Custom color name matches class = A shade of green (#10B981) [OK]
- Confusing custom color with default colors
- Assuming class won't work without import
- Mixing up hex codes
brand-red in Tailwind config but bg-brand-red does not change the background color. What is the likely mistake?Solution
Step 1: Understand Tailwind config changes
Changes to Tailwind config require restarting the dev server to apply.Step 2: Identify the common mistake
Not restarting means new colors won't load, sobg-brand-redwon't work.Final Answer:
Forgetting to restart the development server after config change. -> Option DQuick Check:
Restart server after config edits = Forgetting to restart the development server after config change. [OK]
- Thinking Tailwind doesn't support custom colors
- Mixing background and text classes
- Missing # in hex code (usually caught earlier)
Solution
Step 1: Consider team consistency needs
Using a shared config with named colors ensures everyone uses the same colors.Step 2: Compare options
Inline styles and separate CSS files cause inconsistency and harder updates; letting developers pick freely causes mismatch.Final Answer:
Define all custom colors in Tailwind config and use their names in classes. -> Option AQuick Check:
Central config for colors = consistency and easy updates [OK]
- Using inline styles causing scattered colors
- Ignoring Tailwind config for colors
- Allowing random color choices by team members
