Using Color in UI Design
Practical principles for selecting and implementing colors in user interfaces. From system colors to state variations, learn how to create cohesive, functional design systems.
Building Your UI Color System
Every effective UI needs a structured color system. Start with these three foundational color types and expand as needed.
Primary Color
Your brand's main color. Used for primary actions, key UI elements, and brand recognition. Should be distinctive and appear throughout the interface.
Secondary Color
Complements the primary color. Used for less prominent actions, highlights, and creating visual hierarchy. Should work harmoniously with primary.
Accent Color
Draws immediate attention. Used sparingly for CTAs, important notifications, and focal points. High contrast with primary and secondary.
Semantic Colors (Success, Error, Warning, Info)
Background & Surface Colors
Create depth and hierarchy with subtle variations in background and surface colors. These form the foundation of your interface.
Background Base
The main background color. Should be very light (near white) for light mode or very dark for dark mode. Creates the canvas for content.
Surface
Sits on top of background. Used for cards, modals, and elevated content. Slightly brighter/darker than background to create depth.
Subtle Accent
For alternating rows, subtle highlights, or disabled states. Just barely different from background for gentle distinction.
Interactive State Variations
Every interactive element needs multiple color states. Users must understand when they can interact and receive visual feedback.
Implementation Examples
Copy-paste ready code snippets for CSS variables, Tailwind config, and design tokens.
:root {
/* Brand Colors */
--color-primary: #2D7DD2;
--color-primary-hover: #2464B5;
--color-primary-active: #1B4F8C;
--color-secondary: #7C3AED;
--color-accent: #E8453C;
/* Semantic Colors */
--color-success: #10B981;
--color-success-bg: #D1FAE5;
--color-error: #EF4444;
--color-error-bg: #FEE2E2;
--color-warning: #F59E0B;
--color-warning-bg: #FEF3C7;
--color-info: #3B82F6;
--color-info-bg: #DBEAFE;
/* Backgrounds */
--color-bg-base: #FAFAFA;
--color-bg-surface: #FFFFFF;
--color-bg-subtle: #F5F5F5;
/* Text */
--color-text-primary: #1A1A1A;
--color-text-secondary: #6B6B6B;
--color-text-tertiary: #9A9A9A;
}
Good vs Bad: Common Mistakes
Welcome Back
Continue where you left off
Why it works:
- Strong contrast for text readability
- Single vibrant color for CTA
- Clear visual hierarchy
- Neutral background doesn't compete
Welcome Back
Continue where you left off
Problems:
- Too many competing colors
- Busy gradient background distracts
- Poor text contrast on gradient
- No clear focal point
Why it works:
- Green immediately signals success
- Light background, darker text
- Border adds visual weight
- Follows universal conventions
Problems:
- Red suggests error, not success
- Creates user confusion
- Breaks established patterns
- May cause unnecessary alarm