Options

Configuration Structure

Options: {
canvasStyle: string,
enableToolbar: boolean,
type: 'sankey' | 'chord',
arcCornerRadius: number,
theme: string | SankeyTheme,
nodePalette: string[],
fontColor: string,
edgeOpacity: number,
edgeGradientFill: boolean,
nodeBorderColor: string | null,
canvasStyle: string,
tooltipTheme: 'dark' | 'light',
height: number | string,
locale: LocaleOptions,
direction: TextDirection,
messages: { ... },
diagramLabel: Function,
edgeAriaLabel: Function,
nodeAriaLabel: Function,
nodesGroupLabel: string,
spacing: number,
viewPortHeight: number,
viewPortWidth: number,
width: number | string,
edgeGap: number,
edgeGradientFill: boolean,
edgeOpacity: number,
particleFlow: boolean,
fontColor: string,
fontFamily: string,
fontSize: string,
fontWeight: string,
dimOpacity: number,
animation: { ... },
enabled: boolean,
duration: number,
whitespace: number,
orientation: 'horizontal' | 'vertical',
axisTitles: string[],
nodeBorderColor: string | null,
nodeBorderWidth: number,
nodeWidth: number,
nodePalette: string[],
draggableNodes: boolean,
onNodeClick: Function,
enableTooltip: boolean,
tooltipBGColor: string,
tooltipBorderColor: string,
tooltipFontColor: string,
tooltipId: string,
tooltipTheme: 'dark' | 'light',
tooltipTemplate: Function,
nodeTooltipTemplate: Function,
a11y: { ... },
enabled: boolean,
diagramLabel: string,
description: string,
}

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 derive height from width at a 1.6:1 ratio.

type

Default: 'sankey'

Which projection of the flow model to draw. Both read the same { nodes, edges } data.

Available Options:

  • sankey (default): the layered diagram, ranks in columns or rows
  • chord: a radial diagram with nodes as arcs on a ring and flows as ribbons across the interior, for dense many-to-many relationships

See Chord Diagrams.

orientation

Default: 'horizontal'

Flow direction of the diagram.

Available Options:

  • horizontal (default): ranks in columns, flows left to right
  • vertical: ranks in rows, flows top to bottom

See Orientation and Circular Links.

arcCornerRadius

Default: 6

Chord only. Corner radius in pixels for the rounded outer corners of each node arc on the ring; the inner edge where ribbons meet stays flush. 0 gives sharp corners, and the value is clamped to the ring band width.

theme

Default: undefined

A named built-in theme, a name registered via ApexSankey.registerTheme, or an inline theme object. A theme seeds coordinated visual defaults (palette, colors, background); options you set explicitly still win.

Available Options:

  • light, dark, midnight, mint, sunset: built-in presets
  • any name passed to ApexSankey.registerTheme(name, theme)
  • an inline object with nodePalette, fontColor, edgeOpacity, edgeGradientFill, nodeBorderColor, canvasStyle and tooltipTheme

Defaults to the light appearance when unset. See Themes.

nodePalette

Options.theme.nodePalette

Ordered node fill colors, cycled across nodes that do not set their own color. The inline-theme form of the top-level nodePalette.

fontColor

Options.theme.fontColor

CSS color for node labels. The inline-theme form of the top-level fontColor.

edgeOpacity

Options.theme.edgeOpacity

Opacity of the flow ribbons, from 0 to 1. The inline-theme form of the top-level edgeOpacity.

edgeGradientFill

Options.theme.edgeGradientFill

Fill ribbons with a source to target gradient. The inline-theme form of the top-level edgeGradientFill.

nodeBorderColor

Options.theme.nodeBorderColor

CSS color for the node border, or null to disable it. The inline-theme form of the top-level nodeBorderColor.

canvasStyle

Options.theme.canvasStyle

CSS applied to the SVG root container, typically the background and border. The inline-theme form of the top-level canvasStyle.

tooltipTheme

Options.theme.tooltipTheme

Tooltip color preset, 'dark' or 'light'. The inline-theme form of the top-level tooltipTheme.

nodePalette

Default: undefined

Ordered fill colors cycled across nodes that do not set their own color. Overrides the built-in palette, and a theme sets it for you.

axisTitles

Default: undefined

Titles drawn above each column, or beside each row when vertical: one per rank, which are the axis labels of an alluvial diagram. Index i labels rank i; omit or leave the array short to skip trailing axes. See Alluvial Diagrams.

canvasStyle

Default: 'border: 1px solid #caced0; box-sizing: border-box'

Arbitrary CSS injected onto the SVG root container element.

spacing

Default: 20

Horizontal spacing between node columns in pixels.

enableToolbar

Default: true

Show the zoom/pan toolbar.

viewPortWidth

Default: 800

Internal SVG viewport width in pixels.

viewPortHeight

Default: 500

Internal SVG viewport height in pixels.

nodeWidth

Default: 20

Width of each node rectangle in pixels.

nodeBorderWidth

Default: 1

Border width of each node in pixels.

nodeBorderColor

Default: null

CSS 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

Default: 0.4

Opacity of edges (0-1).

edgeGradientFill

Default: true

When true, edges are filled with a gradient between source and target node colors.

edgeGap

Default: 0

Gap in pixels between adjacent edges at their node connection points.

whitespace

Default: 0.18

Fraction 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

Default: true

When true, hovering a node or edge highlights the connected flow path.

dimOpacity

Default: 0.2

Opacity for dimmed (unrelated) elements when path highlighting is active.

draggableNodes

Default: false

Allow nodes to be repositioned by dragging with a pointer, supporting mouse, touch and pen. Connected flows follow the node live, and the manual position holds until the next render() or update() recomputes the layout.

Available Options:

  • false (default)
  • true

animation

Entrance animation options. Animation is automatically disabled when prefers-reduced-motion is set.

enabled

Options.animation.enabled
Default: true

Whether entrance animation is enabled.

duration

Options.animation.duration
Default: 800

Total duration of the animation in milliseconds.

particleFlow

Default: false

Animate particles drifting along each flow ribbon, with density proportional to the ribbon's value. Purely decorative, and skipped under prefers-reduced-motion.

Available Options:

  • false (default)
  • true

See Particle Flow.

enableTooltip

Default: true

Show edge tooltips on hover.

tooltipId

Default: 'apexsankey-tooltip-container'

HTML id for the tooltip container element.

tooltipBGColor

Default: '#FFFFFF'

Background color of the tooltip.

tooltipBorderColor

Default: '#E2E8F0'

Border color of the tooltip.

tooltipFontColor

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

Default: '#212121'

CSS color for node labels.

fontFamily

Default: ''

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

fontSize

Default: '14px'

CSS font-size for node labels.

fontWeight

Default: '400'

CSS font-weight for node labels.

a11y

WCAG 2.1 AA accessibility options.

enabled

Options.a11y.enabled

Whether accessibility features are enabled.

diagramLabel

Options.a11y.diagramLabel

Overrides the auto-generated aria-label on the SVG root.

description

Options.a11y.description

Populates the <desc> element for a longer optional description.

locale

Localization and text-direction options. See Localization and RTL for worked examples.

direction

Options.locale.direction
Default: 'ltr'

Text and layout direction. 'rtl' mirrors the diagram horizontally so flows read right-to-left and sets dir="rtl" on the container. 'auto' defers to the document or element's inherited direction.

Available Options:

  • ltr (default)
  • rtl
  • auto

messages

Options.locale.messages

Overrides for the screen-reader strings the diagram generates. Supply any subset; unset keys keep their English defaults (exported as DEFAULT_SANKEY_MESSAGES). Visible tooltips are localized separately through tooltipTemplate and nodeTooltipTemplate.

diagramLabel

Options.locale.messages.diagramLabel

Builds the SVG root aria-label. Receives { nodeCount, flowCount, largestFlow? }, where largestFlow is { source, target, value } when a value-bearing flow exists.

edgeAriaLabel

Options.locale.messages.edgeAriaLabel

Builds an edge's aria-label. Receives { source, target, value }.

nodeAriaLabel

Options.locale.messages.nodeAriaLabel

Builds a node's aria-label. Receives { name, incoming?, outgoing? }, where incoming is { total, sources } and outgoing is { total, targets }.

nodesGroupLabel

Options.locale.messages.nodesGroupLabel
Default: 'Sankey nodes'

aria-label for the group element wrapping all nodes.