Skip to content

Theming

KymaProvider accepts a theme prop that controls the visual appearance of all embedded components. The SDK expresses every visual primitive as a flat record of 26 design tokens (KymaTheme), which are emitted as CSS custom properties (--kyma-*) on the provider's root element.

Token table

All colour values are HSL triplet strings without the hsl() wrapper (e.g. "213 26% 7%"), compatible with Tailwind's hsl(var(--kyma-*)) pattern. radius is a CSS length. fontSans / fontMono are CSS font-stack strings.

TokenCSS variableDescription
background--kyma-backgroundPage / panel background
surface--kyma-surfaceSlightly elevated surface (toolbar, sidebar)
foreground--kyma-foregroundDefault text colour
border--kyma-borderSubtle dividers and outlines
borderStrong--kyma-border-strongStronger borders (e.g. input focus ring adjacent)
input--kyma-inputInput field border
ring--kyma-ringFocus ring colour
primary--kyma-primaryBrand accent (buttons, active states)
primaryForeground--kyma-primary-foregroundText on primary backgrounds
secondary--kyma-secondarySecondary / ghost buttons background
secondaryForeground--kyma-secondary-foregroundText on secondary backgrounds
destructive--kyma-destructiveDanger states (delete, error)
destructiveForeground--kyma-destructive-foregroundText on destructive backgrounds
muted--kyma-mutedMuted backgrounds (empty states, badges)
mutedForeground--kyma-muted-foregroundSubdued text (captions, labels)
accent--kyma-accentHover highlights, selection backgrounds
accentForeground--kyma-accent-foregroundText on accent backgrounds
card--kyma-cardCard surfaces
cardForeground--kyma-card-foregroundText on card surfaces
popover--kyma-popoverPopover / dropdown backgrounds
popoverForeground--kyma-popover-foregroundText in popovers
brandFrom--kyma-brand-fromGradient start (logo, brand accents)
brandTo--kyma-brand-toGradient end
radius--kyma-radiusBase border radius (CSS length, e.g. "0.625rem")
fontSans--kyma-font-sansSans-serif font stack
fontMono--kyma-font-monoMonospace font stack (editor, code)

Built-in presets

ts
import { kymaDark, kymaLight } from "@kyma-ai/react";
PresetWhen to use
kymaDarkDefault. Dark background (background: "213 26% 7%"). Used when theme is omitted or undefined.
kymaLightLight background (background: "0 0% 100%").

Both presets use system font stacks (ui-sans-serif, ui-monospace) so they do not force a specific brand font onto the host application.

Applying a preset

tsx
import { kymaLight } from "@kyma-ai/react";

<KymaProvider theme={kymaLight} ...>
  {children}
</KymaProvider>

Partial override

Pass any subset of KymaTheme. The SDK merges the overrides over kymaDark:

tsx
<KymaProvider
  theme={{
    primary: "262 83% 58%",          // purple brand
    primaryForeground: "0 0% 100%",
    ring: "262 83% 65%",
    radius: "0.375rem",              // tighter corners
  }}
  ...
>
  {children}
</KymaProvider>

Only the tokens you provide are overridden; the rest inherit from kymaDark.

"inherit" mode

When your host application already defines --kyma-* custom properties in its own CSS, set theme="inherit" to prevent the SDK from emitting any inline token values:

tsx
<KymaProvider theme="inherit" ...>
  {children}
</KymaProvider>

In inherit mode:

  • No --kyma-* vars are set as inline styles on the provider element.
  • Your host CSS variables are respected at their natural cascade specificity.
  • The provider still resolves kymaDark internally for logic that needs token values (e.g. isDark context flag for Monaco's theme); it uses those as fallback values if your vars are not set.

Portal container

Kyma uses Radix UI primitives for dropdowns, dialogs, and tooltips. These portals render into a <div class="kyma-root"> element appended by KymaProvider — outside the component subtree. The provider sets the same --kyma-* inline style on that container so portalled content is always themed correctly, even when it escapes the DOM subtree.

If your application restricts portal rendering (e.g. to a shadow DOM host), you can pass a custom React Query client via queryClient but there is currently no prop to override the portal container. File an issue if you need this.

Reacting to dark/light dynamically

tsx
import { useKymaContext, kymaDark, kymaLight } from "@kyma-ai/react";

function ThemeToggle() {
  const { isDark } = useKymaContext();
  // isDark is true when the background token is perceptually dark
  return <span>{isDark ? "Dark mode" : "Light mode"}</span>;
}

isDark is derived from the background token's lightness component. You can use this to drive external UI (icon variants, charts outside the provider) that need to know the current theme mode.

Using themeToCssVars

If you want to drive your own CSS variables from a KymaTheme record:

ts
import { themeToCssVars, kymaLight } from "@kyma-ai/react";

const vars = themeToCssVars(kymaLight);
// { "--kyma-background": "0 0% 100%", "--kyma-foreground": "214 32% 14%", ... }
Object.assign(document.documentElement.style, vars);

Only tokens present in the partial theme are emitted; passing {} produces an empty object.

An open-source project · MIT licensed.