Skip to content

Options

The object passed to createKlad (or the options prop on the Vue and React components). Only data and nodeSize are required.

Data

OptionTypeDefault
dataNodeData[]Flat array. Every item is { id, parentId?, ...yours }; an unresolvable parentId makes a root and emits a warning.
nodeSizeSize | (item) => SizeDeclared, never measured — see Sizing.
label(item) => string''The text the canvas draws inside a node. Independent of whatever your card renders.

Layout

OptionTypeDefault
orientation'tb' | 'bt' | 'lr' | 'rl''tb'Which way the tree grows.
rtlbooleanfalseMirrors sibling order; the growth direction is unaffected.
spacing{ x?, y?: number }{ x: 16, y: 48 }Gaps between siblings and between levels, in world units.
collapsedByDefaultboolean | (item) => booleanfalseWhich nodes start closed.

Content

OptionTypeDefault
renderNode(element, context) => voidDraws your own card. See Node content. Vue and React use the #node slot and the render prop instead.
lodThresholds{ block: number; label: number }{ block: 0.25, label: 0.6 }The zoom levels at which the canvas switches between a plain shape, a labelled box, and overlay cards.

Appearance

OptionTypeDefault
themePartial<Theme>Colours and weights the canvas draws with. See Theme.
minimapboolean | MinimapOptionsfalse{ position, width, height, silhouetteColour }. silhouetteColour is the one piece your own CSS cannot restyle — set it for a dark host.
zoomLimits{ minK, maxK: number }{ minK: 0.05, maxK: 4 }The floor is lowered automatically — never raised — when the tree is wider than the viewport, so fit() can always show everything.

Behaviour

OptionTypeDefault
animatebooleantrueEvery animation this layer starts on its own: the expand/collapse transition, camera eases, kinetic panning. prefers-reduced-motion: reduce forces it off regardless.
autoPanOnTogglebooleantrueKeeps the toggled node pinned on screen while the layout moves around it.
ringbooleantrueThe one-shot confirmation flash after a single-node toggle.
toggleOnNodeClickbooleanfalseTapping a node's body expands or collapses it. For cards with no room for a toggle button.
workerbooleantrueRenders in a Web Worker. Falls back to the main thread on its own — a CSP that blocks workers, a canvas whose context was already taken — with a warning, never a failure.

Types

ts
type NodeData = { id: string; parentId?: string | null; [key: string]: unknown }
type Size = { w: number; h: number }
type Orientation = 'tb' | 'bt' | 'lr' | 'rl'
type Camera = { x: number; y: number; k: number }

NodeData, Size, Orientation, Camera, Bounds, Theme, LodThresholds, ZoomLimits and Warning are all re-exported from the binding you installed — you never have to reach past it into the core to name something it already hands you.

AGPL-3.0-or-later, with a commercial licence available.