Resources
kanso-ui
The React component library, built on React Aria Components and styled with StyleX. It ships Kanso’s tokens as its base.
Install
Install the package, at the exact version: minor releases below 1.0 can rename props, and each is listed in its UPGRADING.md.
npm install --save-exact @kanso-labs/kanso-ui@0.59.0Components render with no further setup. Every token has a built-in default in light and dark, Kanso’s since 0.53.0, and the library follows the reader’s system unless the app pins a scheme with the colorScheme classes.
import { Button } from '@kanso-labs/kanso-ui'
export function Done() {
return <Button variant="filled">Mark as done</Button>
}Faces
kanso-ui ships no typefaces. Kanso’s three, Roboto Serif, Roboto Flex and Roboto Mono, are open source; this site loads them from Fontsource, with Material Symbols Rounded for its icons.
import '@fontsource-variable/roboto-flex/opsz.css'
import '@fontsource-variable/roboto-serif/opsz.css'
import '@fontsource-variable/roboto-mono/index.css'Tokens and themes
Every token is a --kui-* custom property, listed on the Tokens pages, and the components read each one before their built-in value, so an app themes them by overriding it on :root or inside a ThemeScope.
The components carry their values inside their own styles, though, and declare none of those properties. In your own CSS a name resolves only where something declares it: your overrides, or tokens.css. So give each one its value as the fallback, in light-dark() where the schemes differ, which follows a pinned scheme as the components do:
.summary {
background: var(--kui-color-kanso-surface, light-dark(#ffffff, #1c1c1c));
border-radius: var(--kui-radius-kanso-xl, 20px);
color: var(--kui-color-ink, light-dark(#1a1a1a, #ececec));
padding: var(--kui-spacing-kanso-lg, 16px);
}tokens.css lists those properties, a reference rather than a runtime dependency. A page that loads it declares every colour on :root under prefers-color-scheme, and those declarations win over a pin, so an app that pins a scheme or a product does not load it. A product brings its colour as a theme it builds once from its palette with defineProductTheme, which checks every pair against Kanso’s contrast targets, then hands to ThemeScope’s productTheme, or puts on <html> with productThemeStyle.