Skip to main content

Colors

This is a comprehensive, science-based, and developer-proof UI Color Guideline that follows modern design and accessibility standards such as WCAG 2.1, Material Design, Design Tokens, and inclusive UX principles.


✅ TL;DR

  • Use only defined color tokens (ask the designer if unsure)
  • Always apply hover, active, focus, and disabled states
  • Check color contrast using accessibility tools
  • Use semantic tokens for logic (e.g., error, success) not brand color names
  • Don’t create new shades — use the ones from the system
  • Document new uses if you have to extend the system
  • Ask: “Will a color-blind person still understand this UI?”

🎯 Purpose of Color in UI

Color in user interfaces is not decoration — it conveys meaning, hierarchy, interactivity, and status. Misusing color can lead to confusion or inaccessibility. Good color usage:

  • Improves usability
  • Highlights priority elements
  • Communicates emotion and intent
  • Enhances branding (e.g., this website is from the AET research group)

🧠 Color Psychology (What Colors Mean)

Use colors intentionally to match their psychological impact:

ColorMeaning & Use Cases
BlueTrust, safety, calm – good for primary actions, links, systems, peace, loyalty, competence
RedError, danger, urgency – use for destructive actions, errors, excitement, strength, love, energy
GreenSuccess, confirmation, positive status – use for success messages, nature, healing, freshness, quality
YellowWarning, attention – good for non-critical warnings, creativity, happiness, warmth, cheer
OrangeActivity, progress, mild warnings, confidence, bravery, sociability
PurpleCreativity, premium, mystery – good for onboarding, premium features, royalty, luxury, spirituality, ambition
Black/GrayNeutral, structure – used for base text, dividers, backgrounds, formality, dramatic, security
WhiteClean, open background, neutral space, honest, innocence, simplicity

Use color to reinforce meaning, not as the only indicator (e.g., not only a red button but also an error icon and label).


❗️Color Categories You Need

To build a consistent and accessible design system, it’s essential to define a set of semantic color categories. These categories group colors by their functional role in the UI, such as backgrounds, text, borders, and states, rather than by their visual appearance. This structure ensures clarity, scalability, and easier maintenance across light and dark themes. Below is a list of recommended color categories that should cover all common use cases in modern web applications. For some applications more or not all colors are needed.

CategoryDescriptionExamples
PrimaryBrand/main interaction color (sometimes two primary colors from the same color family can be helpful)primary buttons, important headers
SecondaryOptional second brand color (sometimes two secondary colors from the same color family can be helpful)accent buttons, active states
Tertiary / AccentSupporting color for highlightshighlights, tags, borders
NeutralGrayscale spectrum for text, backgroundstext, backgrounds, borders
Success / Warning / Error / InfoStatus colors for system feedbackform validation, alerts, toasts
BackgroundsDefault, surface, elevated, modal backgroundspage background, overlays
BordersDividers, focus ringsseparators, outlines
TextNormal, muted, disabled, inverted textstexts, links

Background Colors

Background NameDescription
PageMain page background
SurfaceDefault surface (e.g., cards, modals)
Surface-hoverHover state of the surface
Surface-activeActive/pressed state
SubtleVery light backgrounds for grouping
InverseBackground on dark sections (e.g., footer)
BackdropOverlay backgrounds (e.g., modals, drawers)

Text Colors

Token NameDescription
PrimaryMain content text
SecondaryLess important supporting text
DisabledText on disabled elements
InverseText on dark backgrounds
BrandText colored with brand identity
LinkDefault link text
ErrorError messages or labels
WarningWarning messages or labels
SuccessSuccess messages or labels

🌘 States & Shadings

Define state variants for each interactive color:

StateDescriptionUse
BaseDefault appearanceDefault button color
HoverOn mouse hoverSlightly darker/lighter shade
ActiveOn press/clickStronger contrast for click
DisabledOn keyboard focusMuted, low contrast
FocusInactive or unavailable stateAdd visible outline (focus ring)

Use 4–8 shades per color for UI flexibility (e.g., primary-100 to primary-900).

Light & Dark Mode

Define at least two themes: Light and Dark. Use the same semantic token names, different values.

Example Values:

TokenLight ValueDark Value
Primary#000000#FFFFFF
Surface#FFFFFF#121212
Error#D32F2F#EF9A9A
🚫

Don’t invert colors blindly — adjust saturation and contrast to maintain legibility and mood.

🧩 Design Tokens

Design tokens are platform-agnostic variables that store visual design values like colors, spacing, typography. This creates consistency, scalability, and theme-ability across platforms. A well-structured token system helps you separate raw design values from their usage context.

The token system is typically divided into three layers:

  1. Primitives (Base Tokens): Raw values like colors, typography, spacing — defined without any specific meaning.

    TokenExampleDescription
    color.blue.500#0078F0A raw color swatch
    font.size.md16pxA specific font size
    spacing.sm8pxA spacing unit

    These tokens do not carry semantic meaning. They’re like your raw material.

    🚫

    Never use primitives in the code. Use semantic tokens instead.

  2. Semantic Tokens: Tokens with a specific purpose in your design system. These reference primitives.

    TokenReferencesDescription
    color.text.primarycolor.gray.900Main body text
    color.bg.surfacecolor.gray.50Default card background
    color.brand.primarycolor.blue.500Main interaction color

    Semantic tokens allow you to swap out themes (e.g., light/dark mode) without changing the meaning.

  3. Component Tokens (Optional Layer): Tokens scoped to specific components for full flexibility and design control.

    TokenDescription
    button.primary.bgBackground of primary button
    button.primary.textText color of primary button
    input.border.focusBorder color when input is focused

    These are especially helpful when you want to override styles for a specific component without affecting the whole system.

📌 Best Practices

  • Always define primitives first, then reference them through semantic tokens.
  • Use semantic names (text.primary, bg.surface) instead of visual ones (blue.500) in your UI.
  • Keep component tokens optional – only add them when you need overrides or granular control.
  • Ensure all tokens are documented in one central source of truth (e.g., Tokens Studio or Style Dictionary).

📍Where and How to Define Your Color Tokens

Defining color tokens properly ensures consistency across design and code. Tokens should be created and maintained in a centralized, version-controlled system and be accessible to both designers and developers.

Tool / FormatUse Case
Tokens Studio (Figma Plugin)Define and sync design tokens visually in Figma
Style DictionaryExport tokens to multiple platforms (CSS, SCSS, JS, Android, iOS, etc.)
Tailwind CSS ConfigDefine colors as part of Tailwind’s theming system
Custom JSON/SCSS/TS FilesFor custom design systems with manual control
CSS Variables (:root)Native browser token usage via --color-token-name

Example Locations for Token Definitions

  • tokens/color-tokens.json → Source of truth (for automated exports)
  • styles/_tokens.scss → Imported into SCSS projects
  • theme/colors.ts → For JS/TS projects using CSS-in-JS or Tailwind
  • global.css or theme.css → For CSS variables (--color-text-primary)

Syncing with Figma

If you’re using Figma, you can:

  1. Use Tokens Studio to define and manage token names and values.
  2. Sync them with your design system libraries.
  3. Export them to JSON for development via Style Dictionary or GitHub Actions.

Always document who is responsible for updating tokens (e.g., brand team, design ops) and how they are versioned.


♿️ Accessibility & Contrast

Follow at least WCAG 2.1 Guidelines

Content TypeMin Contrast Ratio
Normal text4.5:1
Large text (18pt bold or 24pt normal)3:1
UI components (borders, icons)3:1

Use tools like:

Don’t rely on color alone. Always use icons, text labels, or shape indicators too.

🌐 Where to Find Inspiration

📌 Best Practices

  • Never hardcode color values — always use tokens.
  • Test for accessibility in both Light and Dark modes.
  • Name tokens semantically, not visually (text.error > red-500).
  • Use consistent spacing between shades (e.g., 10–20% difference in lightness).
  • Ensure interactive elements have visible focus indicators.
  • Document everything in a centralized Design System or Tokens file (like Figma Tokens, Style Dictionary, or Tokens Studio).