1. Home
  2. Foundations
  3. Product colours

Kanso Labs' brand is ink and paper with no colour of its own. Each product brings one colour, and only one: it fills the product roles (accent, on-accent, accent-soft, on-accent-soft, accent-on-ink, and spotlight with its on- tokens) and nothing else changes. Every Material Design role that follows those roles, kui-color-primary and the focus ring among them, follows the product too.

The base and a sample, live

The base: ink

Focus today50%

See the payments

A sample: violet

Focus today50%

See the payments

The sample: violet

Violet is the sample product colour: it belongs to no product, and the stories, tests and previews use it to show how a product colour lands. It sits far from the status colours (green, amber, rust, red), and it holds high contrast with white. kanso-ui-core exports it as demoProductThemes.violet from @kanso-labs/kanso-ui-core/themes.

RolePalette keyLightDark
accentaccent#6b3fa0 (7.1:1 on paper)#cdb0f5 (9.9:1 on paper)
on-accentonAccent#ffffff (7.4:1)#2a0d4a (8.9:1)
accent-soft / on-accent-softaccentSoft, onAccentSoft#efe6f8 / #3f1d63 (11.1:1)#3b2557 / #eadcfc (10.2:1)
accent-on-inkaccentOnInk#c9a8f0 (8.6:1 on ink)#6b3fa0 (6.3:1 on ink)
spotlightspotlight#6b3fa0#553186

Defining a product's colours

A product keeps its colours as data in its own package: a palette that sets the twelve product roles, every one of them, in light and in dark. kanso-ui-core's defineProductTheme(palette) turns it into a theme. It checks every pair Kanso's usage notes name, and every Material Design pair the libraries draw, against 4.5:1 for text and 3:1 for everything else in both schemes, and throws a ProductThemeError listing each pair that misses. A product passes exactly when it clears what the base clears. Call it once, at module scope, and keep the result as a constant.

import { defineProductTheme } from '@kanso-labs/kanso-ui-core'

const violet = defineProductTheme({
  light: {
    accent: '#6b3fa0', onAccent: '#ffffff',
    accentSoft: '#efe6f8', onAccentSoft: '#3f1d63',
    accentOnInk: '#c9a8f0',
    spotlight: '#6b3fa0', onSpotlight: '#ffffff', onSpotlightMuted: 'rgba(255, 255, 255, 0.8)',
    spotlightButton: '#fafafa', onSpotlightButton: '#3f1d63',
    spotlightTonal: 'rgba(255, 255, 255, 0.16)', spotlightLine: 'rgba(255, 255, 255, 0.6)',
  },
  dark: {
    accent: '#cdb0f5', onAccent: '#2a0d4a',
    accentSoft: '#3b2557', onAccentSoft: '#eadcfc',
    accentOnInk: '#6b3fa0',
    spotlight: '#553186', onSpotlight: '#ffffff', onSpotlightMuted: 'rgba(255, 255, 255, 0.8)',
    spotlightButton: '#ffffff', onSpotlightButton: '#3f1d63',
    spotlightTonal: 'rgba(255, 255, 255, 0.14)', spotlightLine: 'rgba(255, 255, 255, 0.6)',
  },
})

Using a product's colours

  • <ThemeScope productTheme={theme}> draws everything inside it in the product's colours, in whichever scheme is in force, and takes its overlays along. A nested scope can set another product, and a scheme pinned inside it keeps the product.
  • productThemeStyle(theme) returns the same declarations as a style, for a page that puts its theme on <html> without a ThemeScope.
  • A product names no scheme, so it composes with colorScheme.light, colorScheme.dark or a scope's scheme around it or inside it.
  • kanso-ui-core's tokens.css holds the base alone and has no product class. A plain-CSS page that needs one writes it from the theme's changes, the colours the product moves in each scheme.
import { Button, ThemeScope } from '@kanso-labs/kanso-ui'

<ThemeScope productTheme={violet}>
  <Button variant="filled">Label</Button>
</ThemeScope>

Choosing a colour for another product

  1. Pick a hue that no status colour uses: keep away from green (positive), amber and orange (caution), rust (negative) and red (critical).
  2. Find the light-theme accent tone that holds at least 4.5:1 on paper and on surface, and at least 4.5:1 with white text on it. Aim for 7:1, like violet.
  3. Find the dark-theme tone again for the same targets on #121212 and #1c1c1c, with dark text on it (on-accent). Do not invert the light value.
  4. Derive accent-soft (a near-white tint in light, a deep tint in dark) and check its on-accent-soft text at 4.5:1 or more.
  5. Check accent-on-ink at 4.5:1 on ink in both themes.
  6. Write the palette in the product's own package and pass it to defineProductTheme, which checks every pair before the product uses it.

Products without a colour

A product that sets no colour keeps the brand as it is: its accent is ink, and its one highlighted action is the ink button. That is Kanso UI's base, with no product set.