Skip to content

App theming

Last updated 23 Nov 2026

App theming ​

Nubisco groups its products by audience: creatives, engineers, home, fun, education and agents. Colour follows that grouping. An app declares which category it belongs to, and the library resolves that to an accent, in light and dark, with every derived token wired up behind it.

One call, at the app shell, and nothing else sets an accent anywhere.

scss
// your-app/src/styles/theme.scss
@use '@nubisco/ui/styles/theme-api' as nb;

@include nb.app-theme('your-app', $category: 'engineers');
ts
// your-app/src/main.ts
import '@nubisco/ui/styles' // the library, once
import './styles/theme.scss' // your accent

configureNamedTheme({ defaultTheme: 'your-app' })
Follows this page. Use the colour-mode switch in the header to see the other half.
A link
@include nb.app-theme('your-app', $category: 'engineers');

The categories ​

CategoryLightDarkFor
creatives#846201#e8c15aTools people make things with
engineers#5b48c9#a99dffTools people build and operate with
home#086f9e#5ec1e8Things that run in someone's house
fun#b83266#f686aeGames and toys
education#017835#5bbd74Things people learn with
agents#00716f#3cc8c0Working with AI agents

Every value clears WCAG AA (4.5:1) against all four surface layers of its mode. That is a stricter bar than it sounds, and it is the reason two of these values are not the ones originally drafted. Measured against pure white, the first gold read 4.92 and looked signed off, but the library never renders a pure-white surface: on the real page background it read 4.23, and on layer-2 it read 4.01. A colour verified against a surface the product cannot show has not been verified.

tests/categoryContrast.test.ts compiles the real stylesheet, resolves the real custom properties and measures them, so an edit that drops a value below the bar fails in the pre-commit hook, the pre-push hook and CI.

Apps with an identity of their own ​

Most apps take their category's accent. A product whose colour predates this system keeps it, and still declares its category, because the category is what groups products by audience on marketing surfaces even when the app's own colour differs.

scss
@include nb.app-theme(
  'your-app',
  $category: 'creatives',
  $accent: (#0b7285, #41d6e0)
);

The override is an exception, not an option. If you are reaching for it because your category's accent looks wrong on a particular screen, that is a bug in the screen, not a reason to fork the colour.

An accent you supply is held to the same bar: 4.5:1 on all four layers of its mode. app-theme() checks it on every build, and an accent that falls short is repaired, not shipped. Each half that fails is run through a11y-color() and moved to the nearest lightness that clears the bar on the worst layer, keeping its hue, and the build prints exactly what it did:

text
Warning: Accent #f5c400 was 1.34:1 on light surface #e7e8e9, below 4.5:1.
Repaired to #79661d at 4.59:1 on the worst light surface, same HSL hue.
Pass that value to silence this.

Paste the repaired value into your call so the warning goes away and the colour you ship is the one written in your source.

Some hues cannot be made legible without becoming a different colour: a navy lightened far enough to read on a dark layer turns periwinkle. A repair that moves the hue more than 12 degrees (OKLCH) or keeps less than 40% of its chroma is refused, and the build fails with the measurements, the way it always did. Pick a different value for that half.

Repair holds AA, not AAA. An accent at 7:1 would have to sit near L* 35 in light and L* 80 in dark, and the six categories would stop being distinguishable from each other. Text is held to AAA; the accent is not.

assert-accent-contrast() is still there for a value you want to check without theming anything:

scss
// fails the build if the pair does not clear AA on every surface
@debug nb.assert-accent-contrast((#0b7285, #41d6e0));

info is not themed ​

app-theme() moves the primary and everything derived from it. It does not move --nb-c-info. A blue product therefore gets its own primary next to the library's info blue, two unrelated blues on one screen. If that matters, set info (and its -hover and -active) in a theme() call with the same id, and measure it.

Why the library holds no product list ​

There is no app-theme('acta') that looks up Acta in a table. The library holds the category values and nothing else, and the app names its own category.

That is deliberate. A registry of product ids inside the design system would mean cutting a library release every time a product is added or renamed, and it would invert the dependency: the design system would have to know about the things that consume it. Products know about the library. The library does not know about products.

The product-to-category map is a portfolio fact and lives in the workspace standards, not in this package.

What the one call emits ​

The accent becomes a full ramp named accent, anchored at both ends, and the primary roles point at steps of it:

TokenLightDark
--nb-c-primarythe light anchorthe dark anchor
--nb-c-primary-hoverone step darkerone step lighter
--nb-c-primary-activetwo steps darkertwo steps lighter
--nb-c-categorythe category's light valuethe category's dark value

Each carries its paired -a11y foreground, so text on a themed button stays readable without you working it out.

Hover and active are always further from the surface than the base, which is why the base is the worst case for contrast and why testing it is enough.

--nb-c-category travels separately from the accent. For most apps the two are the same value. For an app that overrode its accent they are not, and a surface that groups products by audience wants the category.

The derived tokens, and a trap worth knowing ​

These follow the accent too:

  • --nb-c-primary-subtle
  • --nb-c-selected-edge
  • --nb-c-focus-ring (lifted toward white in dark, so it clears 3:1 on every dark layer)
  • --nb-c-focus-inverse
  • --nb-c-link, --nb-c-link-hover, --nb-c-link-visited
  • --nb-shell-sidebar-bg
  • --nb-shell-sidebar-link-active-bg
  • --nb-shell-sidebar-link-active-color
  • --nb-shell-inspector-resize-color

They are re-emitted inside the theme's own scope, and they have to be. A custom property is substituted at computed-value time on the element that declares it, so --nb-c-focus-ring: var(--nb-c-primary) written at :root freezes to :root's primary. Every descendant inherits that frozen literal, and re-pointing --nb-c-primary further down the tree never reaches it. Measured in Chrome:

text
                        :root      inside [data-nb-theme]
--nb-c-primary          #5c35c4    #5b48c9   follows
--nb-c-focus-ring       #5c35c4    #5c35c4   does not
--nb-c-primary-subtle   #5c35c4…   #5c35c4…  does not

If you derive your own token from the accent, declare it in the same scope that sets the accent, not at :root.

Tinted dark surfaces ​

By default the dark theme is neutral grey, whatever your category. A product can opt in to dark surfaces tinted toward its category instead. It is one call, at boot, next to the others:

ts
// your-app/src/main.ts
import { configureDarkSurfaces } from '@nubisco/ui'

configureDarkSurfaces({ tinted: true })

That puts data-nb-dark-surfaces="tinted" on <html>. If you render the document yourself, writing the attribute there does the same thing, and darkSurfacesAttribute(true) gives a server the attribute to render for the first paint. Nothing changes in your stylesheet: app-theme() already emits the tinted values for your category, and they only apply under the attribute.

useDarkSurfaces() returns isTinted, setTinted() and toggle() for an app that offers it as a setting. Like configureAppearance(), the choice is persisted under nubisco.dark-surfaces by default. Pass storageKey to namespace it, or persist: false if the decision is yours rather than the viewer's.

What changes ​

In dark mode only, every value the dark theme takes from its ramp moves toward the hue of your category's dark accent:

  • the four layer surfaces, their borders and their hovers
  • the whole per-plane set (accent, selected, active, strong borders, field fill and field rule, on all four planes)
  • the inverse pair and its edge, and the classic field preset's values
  • the three text tiers, very slightly

The tint is subtle: OKLCH chroma 0.01 on surfaces (0.0085 on layer 0, rising to 0.0115 on layer 3) and 0.004 on text. Every value keeps the WCAG relative luminance of the grey it replaces, so every contrast ratio the grey ramp was measured at holds. Where 8-bit rounding cannot hold it exactly, a surface, border or hover rounds darker and a text tier rounds lighter, so no pair gets worse. Increased contrast (prefers-contrast: more or data-nb-contrast="more") keeps working on top, with the tinted strong borders.

What does not change ​

  • Light mode. Not one declaration.
  • The dark theme of any document without the attribute. The default compiled CSS is the same as before this existed.
  • Your accent, status colours, charts and every other colour that is not a surface or a text tier.
  • The hue source. The tint follows $category, not an overridden $accent, because the tinted ramps are generated and measured per category.

The values are generated ​

The tinted ramps live in src/styles/variables/_tinted-dark.scss, one map per category with the same shape as the dark ramp. They are generated from the dark ramp in _layers.scss and the accents in _categories.scss by scripts/build-tinted-dark.mjs. After changing either source, regenerate and commit the result:

sh
pnpm run generate:tinted-dark

tests/tintedDark.test.ts fails if the committed file differs from what the generator writes. It also holds every category to the grey ramp's bars on the tinted surfaces: primary and muted text at 7:1 and subtle at 4.5:1 on all four layers, the dark status foregrounds at 4.5:1 on layers 0 and 1, and each depth step within 0.5 ΔL* of the grey ramp's. node scripts/audit-contrast.mjs --tinted prints the full measurements.

Migrating from the shared purple ​

The old shared accent, grape-hyacinth #5c35c4, still works and is unchanged. Nothing breaks by not adopting this.

When you do adopt it, expect the shell to re-tint: the sidebar is a near-black mix of the accent by design, so it follows your category. That is the intended outcome, not a regression, but it is a visible change and worth a look before you ship.

Delete any local accent override at the same time. If your app hardcodes #5c35c4 anywhere outside a changelog, that is the thing this call replaces.