Colors

µCSS provides 11 semantic color roles, each with 7 CSS variable variants, color classes for the main visual components, and utility classes for text, background, and border colors.

Color roles

µCSS defines 11 color roles. Each role is mapped to a color family via the theme file (build/mu.theme.json).

RolePurpose
primaryMain action color — links, buttons, active states
secondarySupporting color — secondary buttons, muted elements
tertiaryAccent color — additional highlights
contrastHigh-contrast color — strong emphasis
sparkLighter variant of contrast — derived from the contrast color family with brighter shades
accentEye-catching color — chromatically distant from primary
popLighter variant of accent — derived from the accent color family with brighter shades
successPositive feedback — validation, confirmations
infoInformational — notices, tips
warningCaution — alerts requiring attention
errorNegative feedback — errors, destructive actions

Note: pop and spark are derived roles — pop uses the same color family as accent, and spark uses the same color family as contrast, both with lighter shade values. They do not appear in the theme JSON.

Live color swatches

RoleBaseBackgroundHoverFocusInverse
primary
secondary
tertiary
contrast
accent
success
info
warning
error
pop (lighter accent)
spark (lighter contrast)

CSS variables per role

Each role generates 7 CSS variables, automatically adapted for light and dark modes:

VariableDescription
--mu-{role}Base color
--mu-{role}-backgroundTinted background (light tint in light mode, dark tint in dark mode)
--mu-{role}-hoverHover state color
--mu-{role}-hover-backgroundHover background
--mu-{role}-focusFocus ring color (semi-transparent)
--mu-{role}-inverseText color on a filled background (#fff or #000)
--mu-{role}-underlineSemi-transparent underline

Example

.custom-banner {
    color: var(--mu-info);
    background-color: var(--mu-info-background);
    border-left: 4px solid var(--mu-info);
}

.custom-banner:hover {
    color: var(--mu-info-hover);
}

Utility classes

µCSS provides 34 utility classes in css/mu.colors.css:

Text color

ClassEffect
.c-primary ... .c-sparkSets color to the role's base color

Text color (inverse)

ClassEffect
.c-inverseSets color to the primary inverse color (white or black, for readable text on filled backgrounds)

Background color

ClassEffect
.bg-primary ... .bg-sparkSets background-color to the role's base color, color to inverse (white/black), and links inherit the inverse color

Border color

ClassEffect
.border-primary ... .border-sparkSets border-color to the role's base color

Text color .c-*

Primary · Secondary · Tertiary · Contrast · Accent · Success · Info · Warning · Error · Pop · Spark

Background .bg-*

Primary Secondary Tertiary Contrast Accent Success Info Warning Error Pop Spark

Border .border-*

Primary Secondary Tertiary Contrast Accent Success Info Warning Error Pop Spark

<p class="c-error">Red text</p>
<div class="bg-accent">Accent background</div>
<div class="border-success" style="border:2px solid">Green border</div>

Note: On <nav> or on a parent of <nav> (e.g. <header>), .bg-* classes also apply a gradient. See Nav.

Color classes by component

The following components accept color classes for all 11 roles:

Button

Filled buttons use the role color as background. Ghost buttons use it as text and border only.

ClassStyle
.btn-primary ... .btn-sparkFilled background with inverse text
.btn-outline.btn-primary ... .btn-outline.btn-sparkTransparent background, colored text and border
.btn-linkLink appearance using primary color
<button class="btn btn-success">Save</button>
<button class="btn btn-outline btn-error">Delete</button>
<button class="btn btn-accent">Highlight</button>
<button class="btn btn-pop">Pop action</button>
<button class="btn btn-spark">Spark action</button>

Alert

ClassStyle
.alert-primary ... .alert-sparkColored text, tinted background
Caution: this action cannot be undone.
<div class="alert alert-warning">Caution: this action cannot be undone.</div>

Badge

Solid badges use the role color as background. Outline badges use it as text and border only.

ClassStyle
.badge-primary ... .badge-sparkFilled background with inverse text
.badge-outline.badge-primary ... .badge-outline.badge-sparkTransparent background, colored text and border
Active Expired
<span class="badge badge-success">Active</span>
<span class="badge badge-outline badge-error">Expired</span>

Card

ClassStyle
.card-primary ... .card-sparkTinted background, shaded header/footer
Note

Card content with a colored left border and tinted background.

<article class="card-info">
    <header>Note</header>
    <p>Card content with a colored left border and tinted background.</p>
</article>

Hero

ClassStyle
.hero-primary ... .hero-sparkGradient background with inverse text

Welcome

<section class="hero hero-primary">
    <h1>Welcome</h1>
</section>

Spinner

ClassStyle
.spinner-primary ... .spinner-sparkColored spinning border
<div class="spinner spinner-success"></div>

Progress

ClassStyle
.progress-primary ... .progress-sparkColored progress bar
<progress class="progress-success" value="75" max="100"></progress>

Forms

Form validation uses a subset of roles:

ClassStyle
.input-successGreen border and focus ring
.input-warningAmber border and focus ring
aria-invalid="true"Red border and focus ring (built-in)

Components with implicit colors

These components use color roles internally but do not expose color classes:

ComponentColors used
Pagination--mu-primary (active), --mu-secondary (borders, disabled)
Tabs--mu-primary (active tab), --mu-secondary (inactive)
Breadcrumb--mu-primary (links), --mu-secondary (dividers, last item)
Accordion--mu-secondary-background (borders)
Table--mu-secondary-background (stripes, hover, borders)
Skeleton--mu-secondary-background (placeholder background)
Modal--mu-secondary (close button)
ToastInherits alert colors via .alert-{role}

Base theme colors

These variables define the overall page appearance and adapt between light and dark modes:

background
color
muted
muted-border
h1
h3
h6
VariableLightDark
--mu-background-color#fffrgb(19, 22.5, 30.5)
--mu-color#373c44#c2c7d0
--mu-muted-color#646b79#8891a4
--mu-muted-border-colorrgb(231, 234, 239.5)rgb(48, 54.5, 69)
--mu-mark-background-colorrgb(252.5, 230.5, 191.5)rgb(252.5, 230.5, 191.5)
--mu-h1-color ... --mu-h6-colorGraded shades from dark to mutedGraded shades from light to muted

The full variable reference is available in Variables.

Pre-built themes

µCSS includes 20 pre-built color themes, each generating a dedicated CSS file (mu.{name}.css). The default theme is azure (mu.css).

Each theme is named after its primary color family and remaps the 11 roles accordingly. Most themes share the same defaults for secondary (slate), tertiary (sand), success (green), info (cyan), warning (amber), and error (red) — the primary, contrast, and accent roles vary per theme. The pop role always derives from accent with lighter shades, and the spark role always derives from contrast with lighter shades.

Available themes: azure (default), red, pink, fuchsia, purple, violet, indigo, blue, cyan, jade, green, lime, yellow, amber, pumpkin, orange, sand, grey, zinc, slate.

To use a theme, load its CSS file instead of the default:

<link rel="stylesheet" href="dist/mu.pink.css">

Themes are defined in build/mu.theme.json. Each entry maps the 9 configurable roles (all except pop and spark) to color families from a palette of 20 colors.

See the Themes page for a live preview of each theme and a complete table showing which color family every theme uses for each role.

Customization

Override role colors on :root to change them globally:

:root {
    --mu-primary: #e63946;
    --mu-primary-hover: #c5303b;
    --mu-primary-focus: rgba(230, 57, 70, 0.375);
    --mu-primary-inverse: #fff;
}

For theme-based color generation, edit build/mu.theme.json and rebuild:

{
    "primary": "red",
    "secondary": "slate",
    "tertiary": "sand",
    "contrast": "indigo",
    "accent": "jade",
    "success": "green",
    "info": "azure",
    "warning": "amber",
    "error": "pink"
}
php build/mu-build.php

Accessibility

  • All color roles are designed to meet WCAG AA contrast requirements in both light and dark modes.
  • The -inverse variant ensures readable text on filled backgrounds by providing #fff or #000 as appropriate.
  • Do not rely on color alone to convey meaning — pair color indicators with text labels or icons for users with color vision deficiencies.
  • The .bg-* utility classes automatically set the text and link colors to the inverse value, preventing contrast issues.

See also: Variables · Dark mode · Button · Alert