esc
navigate select
Browse documentation

Styling

Every visual property is a CSS custom property scoped to .tk-tree — override what you need in a plain stylesheet.

Engineering
Frontend
React
Vue
Svelte
Show code
.tk-tree {
  --tk-accent: #f43f5e;
  --tk-radius: 10px;
}

No Tailwind config, no CSS-in-JS runtime, no build-time theming step — set these on .tk-tree globally, scope them to one instance with a wrapper class or inline style, or set them per-instance via the style prop directly:

<TreeKit
  data={data}
  style={{ "--tk-accent": "#f43f5e", "--tk-radius": "10px" } as React.CSSProperties}
/>

CSS variable reference

VariableDefaultControls
--tk-fontsystem font stackFont family for the whole tree.
--tk-font-size13.5pxBase text size.
--tk-row-height32pxHeight of each row. Matches rowHeight when virtualized.
--tk-indent18pxHorizontal space added per nesting level.
--tk-radius6pxCorner radius for rows and the connector-line branch.
--tk-gap6pxSpace between chevron / checkbox / icon / label.
--tk-fg#1e1e24 / #e5e7ebPrimary text color (light / dark).
--tk-fg-muted#6b7280 / #9ca3afSecondary text — chevron, icons.
--tk-label-colorvar(--tk-fg)Node label text specifically — override this alone to restyle labels without touching icon/chevron color.
--tk-bg-hovertranslucent black/whiteRow background on hover.
--tk-bg-selectedtranslucent accentRow background for the active/selected row.
--tk-accent#6366f1 / #818cf8Checked checkbox fill and highlight accents.
--tk-border#e5e7eb / #2b2d33Connector lines, dividers, and the unchecked checkbox border.
--tk-checkbox-size16pxWidth and height of the checkbox.
--tk-checkbox-radius5pxCorner radius of the checkbox, independent of --tk-radius.
--tk-disabled-opacity0.45Opacity applied to disabled rows and checkboxes.
--tk-highlight-bg / --tk-highlight-fg#fef08a / #1e1e24Search match <mark> colors.
--tk-focus-ring2px ring in --tk-accentbox-shadow used for the focus-visible outline.
--tk-transition-fast120ms easeDuration for hover/selection/chevron transitions.

Overriding just the label color

Labels read from --tk-label-color specifically (it defaults to --tk-fg, the same color everything else uses) — override it alone to restyle label text without also changing icon or chevron color. Give it different values per theme exactly like any other variable, scoped under your own light/dark selectors:

.tk-tree {
  --tk-label-color: #1e3a8a; /* light mode: navy */
}

.dark .tk-tree {
  --tk-label-color: #bfdbfe; /* dark mode: pale blue */
}

Need per-node control instead of a single site-wide color — e.g. color-coding rows by category? Use renderNode and set the color directly from your own data; see Custom Rendering.

Structural overrides with classNames

When a CSS variable isn't enough — you need to target a specific part with more than color/spacing tweaks — pass classNames to attach your own class to each internal part:

<TreeKit
  data={data}
  classNames={{
    root: "my-tree",
    node: "my-tree-row",
    checkbox: "my-checkbox",
    label: "my-tree-label",
  }}
/>

Need full control over markup?

classNames only adds classes to TreeKit's existing DOM structure. For different markup entirely — reordering elements, adding new ones — use renderNode instead; see Custom Rendering.

Dark mode

The default stylesheet includes a @media (prefers-color-scheme: dark) block out of the box — no configuration needed if your app follows the OS theme. If your app toggles a .dark class manually (as this documentation site does with next-themes), override the same variables under your own dark-mode selector; see Themes & Variants.