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 derive height from width at a 1.6:1 ratio.
canvasStyle
'border: 1px solid #caced0; box-sizing: border-box'Arbitrary CSS injected onto the SVG root container element.
spacing
20Horizontal spacing between node columns in pixels.
enableToolbar
trueShow the zoom/pan toolbar.
viewPortWidth
800Internal SVG viewport width in pixels.
viewPortHeight
500Internal SVG viewport height in pixels.
nodeWidth
20Width of each node rectangle in pixels.
nodeBorderWidth
1Border width of each node in pixels.
nodeBorderColor
nullCSS color for the node border. Set to null to disable.
onNodeClick
Callback fired when the user clicks a node. Receives a SankeyNode object.
onNodeClick: (node) => {
console.log('Clicked node:', node);
}
edgeOpacity
0.4Opacity of edges (0–1).
edgeGradientFill
trueWhen true, edges are filled with a gradient between source and target node colors.
edgeGap
2Gap in pixels between adjacent edges at their node connection points.
whitespace
0.18Fraction of vertical space used as margins between nodes (0–1). Lower values produce taller, more compact nodes; higher values add more padding between them.
highlightConnectedPath
trueWhen true, hovering a node or edge highlights the connected flow path.
dimOpacity
0.2Opacity for dimmed (unrelated) elements when path highlighting is active.
animation
Entrance animation options. Animation is automatically disabled when prefers-reduced-motion is set.
enabled
trueWhether entrance animation is enabled.
duration
800Total duration of the animation in milliseconds.
enableTooltip
trueShow edge tooltips on hover.
tooltipId
'apexsankey-tooltip-container'HTML id for the tooltip container element.
tooltipBGColor
'#FFFFFF'Background color of the tooltip.
tooltipBorderColor
'#E2E8F0'Border color of the tooltip.
tooltipFontColor
'#1a1a1a'Font color inside the tooltip.
tooltipTheme
Shortcut for dark/light color presets — overrides tooltipBGColor, tooltipBorderColor, and tooltipFontColor with built-in presets.
Available Options:
- light
- dark
tooltipTemplate
Custom function returning an HTML string for the edge (source→target) tooltip.
tooltipTemplate({ source, target, value }) {
return `
<div style='display:flex;align-items:center;gap:5px;'>
<div style='width:12px;height:12px;background:${source.color}'></div>
<span>${source.title}</span>
<span>→</span>
<div style='width:12px;height:12px;background:${target.color}'></div>
<span>${target.title}</span>
<span>: ${value}</span>
</div>
`;
}
nodeTooltipTemplate
Custom function returning an HTML string for the per-node tooltip.
nodeTooltipTemplate({ node, value }) {
return `
<div style='display:flex;align-items:center;gap:5px;'>
<div style='width:12px;height:12px;background:${node.color}'></div>
<span>${node.title}</span>
<span>: ${value}</span>
</div>
`;
}
fontColor
'#212121'CSS color for node labels.
fontFamily
''CSS font-family for node labels. Falls back to the page default when empty.
fontSize
'14px'CSS font-size for node labels.
fontWeight
'400'CSS font-weight for node labels.
a11y
WCAG 2.1 AA accessibility options.
enabled
Whether accessibility features are enabled.
diagramLabel
Overrides the auto-generated aria-label on the SVG root.
description
Populates the <desc> element for a longer optional description.