Options

Configuration Structure

Options: {
a11y: A11yOptions,
enabled: boolean,
label: string,
canvasStyle: string,
childrenSpacing: number,
containerClassName: string,
contentKey: string,
direction: TreeDirection,
enableAnimation: boolean,
enableBreadcrumb: boolean,
enableSearch: boolean,
enableSelection: TreeSelectionMode,
enableToolbar: boolean,
enableZoomPan: boolean,
groupLeafNodes: boolean,
height: number | string,
highlightOnHover: boolean,
paddingX: number,
paddingY: number,
siblingSpacing: number,
theme: TreeTheme,
viewPortHeight: number,
viewPortWidth: number,
width: number | string,
edgeColor: string,
edgeColorHover: string,
edgeColorMode: EdgeColorMode,
edgeStyle: EdgeStyle,
edgeWidth: number,
fontColor: string,
fontFamily: string,
fontSize: string,
fontWeight: string,
borderColor: string,
borderColorHover: string,
borderRadius: string,
borderStyle: string,
borderWidth: number,
collapseBadgeEnabled: boolean,
enableExpandCollapse: boolean,
externalLabel: ExternalLabelOptions,
align: 'center' | 'left' | 'right',
enabled: boolean,
fontColor: string,
fontFamily: string,
fontSize: string,
fontWeight: string,
offsetX: number,
offsetY: number,
rotation: number,
verticalAlign: 'bottom' | 'middle' | 'top',
nodeBGColor: string,
nodeBGColorHover: string,
nodeClassName: string,
nodeHeight: number,
nodeShadow: string,
nodeShadowHover: string,
nodeStyle: string,
nodeTemplate: Function,
nodeWidth: number,
onNodeClick: Function,
enableTooltip: boolean,
tooltipBGColor: string,
tooltipBorderColor: string,
tooltipFontColor: string,
tooltipFontSize: string,
tooltipId: string,
tooltipMaxWidth: number | undefined,
tooltipMinWidth: number,
tooltipPadding: number,
tooltipTemplate: Function,
tooltipOffset: number,
}

width

Default: '100%'

Width of the canvas. Accepts a pixel number or CSS percentage string.

height

Default: 'auto'

Height of the canvas. Use 'auto' to size to content.

direction

Default: '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

Default: 'name'

Key in the data object used as the node display label.

siblingSpacing

Default: 50

Horizontal distance between sibling nodes in pixels.

childrenSpacing

Default: 50

Vertical distance between a parent node and its children in pixels.

highlightOnHover

Default: true

Highlight the hovered node and its connecting edges.

containerClassName

Default: 'root'

CSS class name for the root SVG container element.

canvasStyle

Default: ''

Arbitrary CSS injected onto the SVG root container element.

enableToolbar

Default: false

Show the zoom/pan toolbar.

enableAnimation

Default: true

Animate node expansion/collapse transitions.

groupLeafNodes

Default: false

Stack leaf nodes vertically instead of spreading them horizontally.

viewPortWidth

Default: 800

Internal SVG viewport width in pixels.

viewPortHeight

Default: 600

Internal SVG viewport height in pixels.

nodeWidth

Default: 50

Width of each node in pixels.

nodeHeight

Default: 30

Height 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

Default: '#FFFFFF'

Default background color of nodes.

nodeBGColorHover

Default: '#FFFFFF'

Background color of nodes on hover.

nodeClassName

Default: 'apextree-node'

CSS class name added to every node element.

nodeStyle

Default: ''

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

Default: 1

Border width of nodes in pixels.

borderStyle

Default: 'solid'

CSS border-style for nodes.

borderRadius

Default: '5px'

CSS border-radius for nodes.

borderColor

Default: '#BCBCBC'

Border color of nodes in their default state.

borderColorHover

Default: '#5C6BC0'

Border color of nodes on hover.

enableExpandCollapse

Default: true

Show expand/collapse buttons on nodes that have children.

expandCollapseButtonBGColor

Default: '#FFFFFF'

Background color of the expand/collapse button.

expandCollapseButtonBorderColor

Default: '#BCBCBC'

Border color of the expand/collapse button.

collapseBadgeEnabled

Default: true

Show the collapse-count badge on collapsed nodes.

collapseBadgeBGColor

Default: '#5C6BC0'

Background color of the collapse-count badge.

collapseBadgeFontColor

Default: '#FFFFFF'

Font color of the collapse-count badge.

collapseBadgeFontSize

Default: '12px'

Font size of the collapse-count badge.

collapseBadgeThreshold

Default: 1

Minimum number of hidden children required before the badge appears.

groupLeafNodesSpacing

Default: 10

Spacing between stacked leaf nodes when groupLeafNodes is true, in pixels.

edgeColor

Default: '#A1A1A1'

Color of the connecting lines between nodes.

edgeColorHover

Default: '#5C6BC0'

Color of connecting lines when highlighted on hover.

edgeWidth

Default: 1

Stroke width of connecting lines in pixels.

enableTooltip

Default: false

Show a tooltip on node hover.

tooltipId

Default: '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

Default: 100

Minimum width of the tooltip in pixels.

tooltipPadding

Default: 8

Inner padding of the tooltip in pixels. Set to 0 when using a custom tooltipTemplate.

tooltipOffset

Default: 10

Distance between the tooltip and the cursor in pixels.

tooltipBGColor

Default: '#FFFFFF'

Background color of the tooltip.

tooltipBorderColor

Default: '#BCBCBC'

Border color of the tooltip.

tooltipFontColor

Default: '#000000'

Font color of tooltip text.

tooltipFontSize

Default: '12px'

Font size of tooltip text.

fontColor

Default: '#000000'

CSS color for node text.

fontFamily

Default: ''

CSS font-family for node text. Falls back to the page default when empty.

fontSize

Default: '14px'

CSS font-size for node text.

fontWeight

Default: '400'

CSS font-weight for node text.

a11y

WCAG 2.1 AA accessibility options for the tree chart.

enabled

Options.a11y.enabled

Enable ARIA semantics and keyboard navigation.

label

Options.a11y.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 simultaneously
  • false — selection is disabled

edgeColorMode

Determines how connecting edge colors are resolved.

Available values: 'default' | 'node'

  • 'default' — edges use edgeColor / 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

Default: false

Toggle 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

Default: true

Allow 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

Default: 100

Horizontal 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

Default: 100

Vertical 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

Options.externalLabel.enabled
Default: false

Render the label outside the node bounds. When false, the in-node nodeTemplate is used as before.

Available Options:

  • false (default)
  • true

align

Options.externalLabel.align
Default: '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

Options.externalLabel.verticalAlign
Default: '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

Options.externalLabel.offsetX
Default: 0

Additional horizontal pixel offset applied after externalLabel.align.

offsetY

Options.externalLabel.offsetY
Default: 0

Additional vertical pixel offset applied after externalLabel.verticalAlign.

rotation

Options.externalLabel.rotation
Default: 0

Rotation in degrees, applied around the label anchor. Use 90 for top-to-bottom vertical labels and -90 for bottom-to-top.

fontColor

Options.externalLabel.fontColor

Override the global fontColor for the external label only.

fontFamily

Options.externalLabel.fontFamily

Override the global fontFamily for the external label only.

fontSize

Options.externalLabel.fontSize

Override the global fontSize for the external label only.

fontWeight

Options.externalLabel.fontWeight

Override the global fontWeight for the external label only.