Color System Architecture

Understanding how Focus UI's color system is structured and how to use colors effectively across utility classes, component modifiers, and CSS variables.

Overview

Focus UI's color system is designed to provide a comprehensive, flexible, and accessible color palette for building consistent user interfaces. The system organizes colors into four distinct categories, each serving a specific purpose in your design.

Color Organization

Colors in Focus UI are organized into four categories:

Color Categories
Brand Colors

Primary, Secondary, Tertiary - These define your application's identity and are used for key interface elements like buttons, links, and navigation.

Semantic Colors

Success, Danger, Warning, Info - Colors with built-in meaning that communicate state and feedback to users (e.g., success messages, error alerts, warnings).

Accent Colors

Purple, Teal, Orange, Pink - Additional colors for decorative purposes, badges, tags, and adding visual variety without semantic meaning.

Neutral Colors

White, Light, Border, Text, Dark, Black - Foundational colors for structure, backgrounds, borders, and typography.

How to Use Colors

Focus UI provides three different ways to apply colors in your projects, each suited to different use cases:

Color Availability Guide
Utility Utility Classes

Apply colors directly to any element using utility classes:

.focus-bg-primary, .focus-text-danger, .focus-bg-success-light

Use when: You need to apply color to custom HTML elements or override component colors.

Component Component Modifiers

Apply colors to Focus UI components using modifier classes:

.focus-btn-primary, .focus-alert-danger, .focus-badge-success

Use when: You're using Focus UI components (buttons, alerts, badges, etc.) and want to apply color variants.

CSS Var CSS Variables

Access raw color values for custom CSS using CSS variables:

var(--focus-color-primary), var(--focus-color-danger-bg), var(--focus-color-border)

Use when: You're writing custom CSS and need direct access to color values for gradients, shadows, or complex styling.

Understanding Color Variants

Most colors in Focus UI come with multiple variants to provide flexibility for different use cases. Here's what each variant means and when to use it:

Variant Purpose Example Usage Availability
base The primary color value Main button background, primary alerts UTILITY COMPONENT
-hover Darker shade for hover states Button hover, link hover backgrounds UTILITY
-light Lighter shade for subtle backgrounds Hover states, secondary backgrounds UTILITY
-lighter Very light shade for backgrounds Section backgrounds, table rows UTILITY
-dark Darker shade for emphasis Text on light backgrounds, borders UTILITY
-bg Background color for components Alert backgrounds, badge backgrounds CSS VAR
-border Border color for components Alert borders, card borders CSS VAR
-text Text color for components Alert text, badge text CSS VAR
Quick Reference

To find the exact color name you need, visit the Color Palette page where you can click any color swatch to copy its name to your clipboard.

CSS Variable Architecture

All Focus UI colors are defined as CSS custom properties (variables) following a consistent naming convention:

Naming Convention
--focus-color-{category}-{variant}

Examples:

  • --focus-color-primary
  • --focus-color-danger-hover
  • --focus-color-success-bg
  • --focus-color-border-light

Using CSS Variables in Custom CSS

You can use these variables in your own stylesheets to maintain consistency with the Focus UI color system:

CSS
/* Using color variables in custom CSS */
.my-custom-element {
  background: var(--focus-color-primary-lighter);
  border: 2px solid var(--focus-color-primary);
  color: var(--focus-color-primary-dark);
}

/* Creating gradients */
.gradient-header {
  background: linear-gradient(
    135deg,
    var(--focus-color-primary),
    var(--focus-color-secondary)
  );
}

/* Using with opacity */
.transparent-overlay {
  background: rgba(59, 130, 246, 0.5); /* Or use var with opacity */
}

Overriding Default Colors

You can customize the entire color system by overriding CSS variables in your own stylesheet. Define your custom values in the :root selector after importing Focus UI:

CSS
/* Load Focus UI first */
@import 'focus-ui.css';

/* Then override colors */
:root {
  /* Change primary color to your brand color */
  --focus-color-primary: #8b5cf6;
  --focus-color-primary-hover: #7c3aed;
  --focus-color-primary-light: #a78bfa;

  /* Change semantic colors */
  --focus-color-success: #10b981;
  --focus-color-danger: #ef4444;
}

Special Purpose Colors

Beyond the standard color families, Focus UI includes specialized color tokens for specific UI patterns and scenarios.

Dark Theme Colors

A complete set of dark mode color tokens for building dark theme interfaces. These colors are optimized for readability and comfort in low-light environments.

Token Value Usage
--focus-color-dark-bg #1e1e1e Main background color for dark theme layouts
--focus-color-dark-border #333333 Border color for dark theme components
--focus-color-dark-text rgba(255, 255, 255, 0.85) Primary text color on dark backgrounds (high contrast)
--focus-color-dark-text-muted rgba(255, 255, 255, 0.6) Secondary text color on dark backgrounds (medium contrast)
--focus-color-dark-text-subtle rgba(255, 255, 255, 0.5) Tertiary text color on dark backgrounds (low contrast)
--focus-color-dark-hover rgba(255, 255, 255, 0.08) Hover state background for interactive elements
--focus-color-dark-active rgba(59, 130, 246, 0.15) Active/selected state background for navigation items
--focus-color-dark-active-text #60a5fa Text color for active/selected items in dark theme
Usage Pattern: These colors are designed to be used together in dark-themed sidebars, navigation menus, and full dark mode layouts. Apply --focus-color-dark-bg as the base, use text variants for hierarchy, and hover/active colors for interactivity.

Overlay Colors

Semi-transparent overlay colors for creating modal backdrops, dropdown shadows, and layered UI elements.

Token Value Usage
--focus-color-overlay rgba(0, 0, 0, 0.5) Standard modal backdrop (50% black opacity)
--focus-color-overlay-light rgba(0, 0, 0, 0.3) Lighter overlay for dropdowns and tooltips (30% black opacity)
--focus-color-white-overlay rgba(255, 255, 255, 0.15) Light overlay for hover effects on dark backgrounds
Usage Pattern: Use --focus-color-overlay for modal backdrops (z-index 1040), --focus-color-overlay-light for subtle overlays, and --focus-color-white-overlay for hover effects in dark-themed components.

Dedicated color tokens for navbar components, providing semantic theming for navigation bars across different visual styles.

Token Value Usage
--focus-color-navbar-bg #343a40 Default navbar background (dark gray)
--focus-color-navbar-bg-dark #1a1d29 Darker navbar variant background
--focus-color-navbar-bg-light #f8f9fa Light navbar variant background
--focus-color-navbar-text rgba(255, 255, 255, 0.8) Default text color in navbar (80% white opacity)
--focus-color-navbar-text-hover #ffffff Text color on hover (100% white)
--focus-color-navbar-hover-bg rgba(255, 255, 255, 0.1) Background color for navbar item hover states
--focus-color-navbar-border #4f5962 Border color for navbar separators and dividers
Usage Pattern: These colors are automatically applied by the .focus-navbar component. Use .focus-navbar-dark or .focus-navbar-light modifiers to switch between color schemes. You can also override these variables in custom CSS for brand-specific navbar theming.

Surface & Interaction Colors

Subtle colors for creating depth, surfaces, and interactive feedback in the UI.

Token Value Usage
--focus-color-hover rgba(0, 0, 0, 0.04) Generic hover state for light backgrounds (4% black tint)
--focus-color-surface #ffffff Base surface color for cards, modals, and elevated components
--focus-color-primary-subtle rgba(0, 123, 255, 0.1) Very subtle primary tint for highlights or backgrounds (10% primary opacity)
Usage Pattern: Use --focus-color-hover for custom hover effects on buttons, list items, or cards. --focus-color-surface is ideal for modal backgrounds and card surfaces. --focus-color-primary-subtle provides a gentle primary accent without overwhelming the design.
Next Steps

Now that you understand how the color system works: