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.