Skip to content

Color

Colour comes in two layers. Semantic roles describe what a colour is for — accent, surface, text, border — and follow the light/dark theme. The named palette is a fixed set of colours for cases that need a specific hue: charts, illustrations, status chips, or a brand accent that is not the primary one.

Both are --nc-* tokens, so either can be overridden at runtime.

Token Utility Use for
--nc-surface bg-surface Page background
--nc-surface-raised bg-surface-raised Cards, code blocks, wells
--nc-accent bg-accent / text-accent Primary actions and brand
--nc-accent-contrast text-accent-contrast Text and icons on accent
--nc-text text-default Primary copy
--nc-text-muted text-muted Secondary copy, metadata
--nc-border border-default Dividers and edges
--nc-ring ring-accent Focus ring

The pairing rule is simple: an accent background gets text-accent-contrast. It is not always white — in the dark theme the accent is lighter and the contrast colour is dark.

<button class="bg-accent text-accent-contrast rounded-md border-0 p-2">Save</button>
<p class="text-muted">Secondary copy stays on the surface, not on the accent.</p>
Group Names
Base red, pink, orange, yellow, green, brown, teal, cyan, blue, pine
Neutral white, gray-1 … gray-10, black
Theme primary, secondary, success, info, warning, danger, light, dark

Each name has three utilities:

Property Class pattern Example
Background bg-{name} bg-primary
Text clr-{name} clr-gray-7
SVG fill fill-{name} fill-success
<div class="bg-primary">primary</div>
<p class="clr-secondary">secondary text</p>
<svg class="fill-success" width="16" height="16" aria-hidden="true"><circle cx="8" cy="8" r="6" /></svg>

The theme aliases point at the base palette, so changing one token retints every class that uses it:

:root {
--nc-pine: oklch(52% 0.14 165);
}

There is no numeric ramp like blue-500. The palette is a fixed named set, and mixing is done with color-mix().

The eight theme colours also have a light/dark ladder, levels 1 through 5 (10% to 50% mixed toward white or black):

<div class="bg-primary">primary</div>
<div class="bg-primary-light-3">lighter</div>
<div class="bg-primary-dark-3">darker</div>
<div class="clr-secondary-light-2">text</div>
<div class="fill-success-dark-4">icon</div>

The shades are computed at runtime with color-mix(in oklch, …), so they follow the palette token and stay in the current theme. They are close to the classic lighten() / darken() steps, not byte-identical, because the mix happens in OKLCH in the browser.

Knobs: --bg, --clr, --fill.

For anything outside the fixed ladder, mix in CSS. Mix with the surface for an opaque tint, or with transparent for an alpha tint:

.tint {
background: color-mix(in oklch, var(--nc-accent) 12%, var(--nc-surface));
}
.alpha-tint {
background: color-mix(in oklch, var(--nc-accent) 16%, transparent);
}
.shade {
background: color-mix(in oklch, var(--nc-accent) 78%, black);
}
Opaque tintMixes with –nc-surface, so it stays solid over anything.
Alpha tintMixes with transparent, so the background shows through.
ShadeMix toward black for a deeper, heavier tone.

Use in oklch so the hue stays stable while lightness changes. Mixing in srgb works too, but it tends to go grey in the middle.

A few useful patterns:

/* Hover fill for a quiet button */
.button:hover {
background: color-mix(in oklch, var(--nc-accent) 10%, var(--nc-surface));
}
/* Selected row */
.row-selected {
background: color-mix(in oklch, var(--nc-accent) 12%, transparent);
}
/* Soft border */
.panel {
border-color: color-mix(in oklch, var(--nc-accent) 30%, var(--nc-border));
}

For chroma changes, use relative colour syntax rather than a precomputed class:

.saturated {
color: oklch(from var(--nc-primary) l calc(c * 1.2) h);
}

opacity fades the whole element, including its children. color-mix() fades only the colour. Use opacity for disabled states and entering elements; use a mixed colour when the text inside should stay crisp.

<button class="bg-accent text-accent-contrast rounded-md border-0 p-2" style="opacity: 0.5">
Disabled action
</button>

Do not use opacity to make text quieter; it lowers contrast for everything inside. Use text-muted or a mixed text colour instead. See Opacity for the scale.

fill-* classes colour an SVG from the palette. For icons that should follow the surrounding text, use currentColor and set the text colour on the parent:

<a href="#" class="text-accent">
<svg width="16" height="16" viewBox="0 0 16 16" aria-hidden="true" fill="currentColor">
<circle cx="8" cy="8" r="6" />
</svg>
Accent icon
</a>
  • Do not use colour alone to convey state. Pair it with text, an icon, or a border.
  • text-accent on bg-surface is not automatically accessible; the default accent is tuned for links, not for small text on every surface.
  • Check contrast in both themes, not just the one you are looking at.
  • color-mix() and light-dark() are modern CSS; keep a meaningful fallback for critical UI.
  • For gradients built from these tokens, see Gradients.

The class is the markup shorthand. The same style in a component stylesheet:

.cta {
background-color: var(--nc-accent);
color: var(--nc-accent-contrast);
}
.meta {
color: var(--nc-text-muted);
}

The Sass subpackage exposes the same values: nc.nc-color("accent") and nc.nc-color("text-muted"). Named palette colours use nc.nc-palette("primary"). See Sass subpackage.

A breakpoint is the same declaration inside a media query; you do not need a second class.