Options
Configuration Structure
Options: {}width
'100%'Width of the canvas. Accepts a pixel number or CSS percentage string.
height
'auto'Height of the canvas. Use 'auto' to size to content.
direction
'top'Controls the direction the tree grows from the root node.
Available Options:
- top — root at the top, children flow downward (default)
- bottom — root at the bottom, children flow upward
- left — root on the left, children flow rightward
- right — root on the right, children flow leftward
contentKey
'name'Key in the data object used as the node display label.
siblingSpacing
50Horizontal distance between sibling nodes in pixels.
childrenSpacing
50Vertical distance between a parent node and its children in pixels.
highlightOnHover
trueHighlight the hovered node and its connecting edges.
containerClassName
'root'CSS class name for the root SVG container element.
canvasStyle
''Arbitrary CSS injected onto the SVG root container element.
enableToolbar
falseShow the zoom/pan toolbar.
enableAnimation
trueAnimate node expansion/collapse transitions.
groupLeafNodes
falseStack leaf nodes vertically instead of spreading them horizontally.
viewPortWidth
800Internal SVG viewport width in pixels.
viewPortHeight
600Internal SVG viewport height in pixels.
nodeWidth
50Width of each node in pixels.
nodeHeight
30Height of each node in pixels.
nodeTemplate
Custom function returning an HTML string rendered inside each node.
nodeTemplate: (content) => {
return `
<div style='display:flex;justify-content:center;
align-items:center;text-align:center;height:100%;'>
${content}
</div>
`;
}
nodeBGColor
'#FFFFFF'Default background color of nodes.
nodeBGColorHover
'#FFFFFF'Background color of nodes on hover.
nodeClassName
'apextree-node'CSS class name added to every node element.
nodeStyle
''Inline CSS string applied to each node element.
onNodeClick
Callback fired when the user clicks a node. Receives the raw node data object.
onNodeClick: (node) => {
console.log('Clicked:', node);
}
borderWidth
1Border width of nodes in pixels.
borderStyle
'solid'CSS border-style for nodes.
borderRadius
'5px'CSS border-radius for nodes.
borderColor
'#BCBCBC'Border color of nodes in their default state.
borderColorHover
'#5C6BC0'Border color of nodes on hover.
enableExpandCollapse
trueShow expand/collapse buttons on nodes that have children.
expandCollapseButtonBGColor
'#FFFFFF'Background color of the expand/collapse button.
expandCollapseButtonBorderColor
'#BCBCBC'Border color of the expand/collapse button.
collapseBadgeEnabled
trueShow the collapse-count badge on collapsed nodes.
collapseBadgeBGColor
'#5C6BC0'Background color of the collapse-count badge.
collapseBadgeFontColor
'#FFFFFF'Font color of the collapse-count badge.
collapseBadgeFontSize
'12px'Font size of the collapse-count badge.
collapseBadgeThreshold
1Minimum number of hidden children required before the badge appears.
groupLeafNodesSpacing
10Spacing between stacked leaf nodes when groupLeafNodes is true, in pixels.
edgeColor
'#A1A1A1'Color of the connecting lines between nodes.
edgeColorHover
'#5C6BC0'Color of connecting lines when highlighted on hover.
edgeWidth
1Stroke width of connecting lines in pixels.
enableTooltip
falseShow a tooltip on node hover.
tooltipId
'apextree-tooltip-container'HTML id for the tooltip container element.
tooltipTemplate
Custom function returning an HTML string for the tooltip content.
tooltipTemplate: (content) => {
return `
<div style='display:flex;justify-content:center;
align-items:center;text-align:center;height:100%;'>
${content}
</div>
`;
}
tooltipMaxWidth
Maximum width of the tooltip in pixels. undefined means unconstrained.
tooltipMinWidth
100Minimum width of the tooltip in pixels.
tooltipPadding
8Inner padding of the tooltip in pixels. Set to 0 when using a custom tooltipTemplate.
tooltipOffset
10Distance between the tooltip and the cursor in pixels.
tooltipBGColor
'#FFFFFF'Background color of the tooltip.
tooltipBorderColor
'#BCBCBC'Border color of the tooltip.
tooltipFontColor
'#000000'Font color of tooltip text.
tooltipFontSize
'12px'Font size of tooltip text.
fontColor
'#000000'CSS color for node text.
fontFamily
''CSS font-family for node text. Falls back to the page default when empty.
fontSize
'14px'CSS font-size for node text.
fontWeight
'400'CSS font-weight for node text.
a11y
WCAG 2.1 AA accessibility options for the tree chart.
enabled
Enable ARIA semantics and keyboard navigation.
label
Override the default aria-label ("Organizational chart") on the root SVG.
theme
Built-in color theme preset for the chart.
Available values: 'light' | 'dark' | 'custom'
Use 'custom' to fully control colors via the individual color options.
enableBreadcrumb
Show a breadcrumb trail above the chart that tracks the currently focused node path.
enableExpandCollapseZoom
Automatically zoom the viewport to fit the visible subtree when a node is expanded or collapsed.
enableSearch
Enable the built-in search bar that highlights matching nodes in the tree.
enableSelection
Enable node selection. Controls the selection mode.
Available values: 'single' | 'multi' | false
'single'— only one node can be selected at a time'multi'— multiple nodes can be selected simultaneouslyfalse— selection is disabled
edgeColorMode
Determines how connecting edge colors are resolved.
Available values: 'default' | 'node'
'default'— edges useedgeColor/edgeColorHover'node'— edges inherit the color of the source node
edgeStyle
Shape of the connecting lines between nodes.
Available values: 'curved' | 'orthogonal' | 'straight'
nodeShadow
CSS box-shadow value applied to each node in its default state.
nodeShadowHover
CSS box-shadow value applied to each node on hover.
expandCollapseOnNodeClick
falseToggle a node's expansion when its body is clicked, in addition to the dedicated +/- button. The cursor becomes a pointer on clickable nodes, and the toggle fires before onNodeClick so the user callback sees the post-toggle node state.
Available Options:
- false (default)
- true
enableZoomPan
trueAllow mouse-wheel zoom and drag-to-pan on the canvas. Set to false to lock the viewport and hide the toolbar's zoom buttons.
Available Options:
- true (default)
- false
paddingX
100Horizontal padding around the rendered tree, in pixels. Adds breathing room between the leftmost/rightmost nodes (and any external labels that extend past them) and the SVG viewBox edge.
paddingY
100Vertical padding around the rendered tree, in pixels. Useful when leaf nodes have rotated externalLabel content that extends past the marker bounds.
externalLabel
Render the node's label as an SVG <text> element positioned outside the node bounds instead of inside the nodeTemplate. The node box still renders (background, border, border-radius), so pair with a small nodeWidth / nodeHeight and borderRadius: '50%' for a marker-style look with a floating label.
When externalLabel.enabled resolves to true for a node, the in-node template is suppressed for that node. Each field can also be set per-node via NestedNode.options.externalLabel, layered onto the global config.
enabled
falseRender the label outside the node bounds. When false, the in-node nodeTemplate is used as before.
Available Options:
- false (default)
- true
align
'center'Horizontal placement of the label relative to the node.
Available Options:
'center'(default) — label is centered on the node horizontally'left'— label sits to the left of the node (text is right-anchored)'right'— label sits to the right of the node (text is left-anchored)
verticalAlign
'middle'Vertical placement of the label relative to the node.
Available Options:
'middle'(default) — label is centered on the node vertically'top'— label sits above the node (text is bottom-anchored)'bottom'— label sits below the node (text is top-anchored)
offsetX
0Additional horizontal pixel offset applied after externalLabel.align.
offsetY
0Additional vertical pixel offset applied after externalLabel.verticalAlign.
rotation
0Rotation in degrees, applied around the label anchor. Use 90 for top-to-bottom vertical labels and -90 for bottom-to-top.
fontColor
Override the global fontColor for the external label only.
fontFamily
Override the global fontFamily for the external label only.
fontSize
Override the global fontSize for the external label only.
fontWeight
Override the global fontWeight for the external label only.