Skip to content
kitn AI/UI

Theming

Override --color-* design tokens on :root to rebrand every kai-* web component at once. Because inherited CSS pierces the Shadow DOM boundary, a single CSS rule propagates into all components automatically.

The kit’s appearance is driven entirely by CSS custom properties defined in theme.css. Each token follows a semantic naming convention borrowed from shadcn/ui — names describe purpose (--color-primary), not hue (--color-blue) — and surface/text pairs come together:

Token pairControls
--color-background / --color-foregroundPage/chat surface and text
--color-primary / --color-primary-foregroundButtons, active states, accents
--color-secondary / --color-secondary-foregroundSecondary buttons, chips
--color-muted / --color-muted-foregroundSubdued surfaces and placeholder text
--color-card / --color-card-foregroundMessage bubbles, panels
--color-borderDividers and input outlines
--color-inputInput field background
--color-destructive / --color-destructive-foregroundError and danger states
--color-ringFocus ring (blue by default for WCAG AA contrast)
--color-sidebarConversation sidebar background
--color-code-foregroundInline code text and chip accent

Border radii are controlled by --radius (default 0.6rem); --radius-sm, --radius-md, --radius-lg, and --radius-xl derive from it automatically.

The kit injects its own scoped CSS into each component’s Shadow DOM automatically — no import required to get started. Import theme.css only to override tokens:

import '@kitn.ai/ui/theme.css';

Or via CDN:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@kitn.ai/ui/theme.css">

Set your overrides on :root after importing theme.css:

:root {
--color-background: hsl(0 0% 6%);
--color-foreground: hsl(0 0% 96%);
--color-primary: hsl(271 91% 65%);
--color-primary-foreground: hsl(0 0% 100%);
--color-muted: hsl(0 0% 12%);
--color-muted-foreground: hsl(0 0% 55%);
--color-border: hsl(0 0% 16%);
--color-card: hsl(0 0% 10%);
--color-card-foreground: hsl(0 0% 96%);
--radius: 0.5rem;
}

The kit ships both light and dark token sets. Switch modes by toggling the dark class on <html> (or any ancestor):

document.documentElement.classList.toggle('dark');

The .dark selector in theme.css redefines every --color-* token for dark surfaces. Override inside .dark to customize the dark-mode palette:

:root {
--color-primary: hsl(271 91% 65%); /* light mode */
}
.dark {
--color-primary: hsl(271 91% 75%); /* dark mode — brighter for contrast */
}

Every --color-* token resolves through a --kai-color-* alias before falling back to its default. Override the --kai-color-* form to rebrand without importing or redefining the entire theme.css token set:

:root {
--kai-color-primary: hsl(271 91% 65%);
--kai-color-primary-foreground: hsl(0 0% 100%);
--kai-radius: 0.375rem;
}

This is the lightest-weight override path — no stylesheet import needed.

The kit exposes four namespaced typography tokens. Override them to adjust the size of UI chrome (labels, badges, controls) globally:

TokenDefaultApplies to
--kai-text-caption0.6875remMicro labels, badges, sub-counts
--kai-text-meta0.75remControls, toggles, captions
--kai-text-body0.875remPrimary reading text
--kai-text-title1remEmphasis, headers
:root {
--kai-text-body: 0.9375rem; /* bump reading text to 15px */
}

Message and markdown reading size scales separately via the proseSize prop — see Appearance settings below.

Non-color appearance is controlled by kai-chat attributes (and the matching ChatConfig props in the SolidJS layer):

SettingValuesPurpose
proseSizexs · sm · base · lgMessage / markdown text size
codeThemeany Shiki theme nameSyntax-highlight theme for code blocks
codeHighlighttrue / falseDisable code highlighting entirely (no Shiki loaded)
<kai-chat prose-size="base" code-theme="github-dark-dimmed"></kai-chat>

The full list of overridable tokens lives in theme.css (shipped at @kitn.ai/ui/theme.css). For a browser-ready version with :root and .dark blocks pre-separated, use @kitn.ai/ui/theme.tokens.css — it is auto-generated from theme.css and never drifts.