Charts
Sankey
Flows between stages — budgets to departments, traffic sources to pages.
import '@reactloom/charts/styles.css';
import { Sankey } from '@reactloom/charts';Examples
Budget allocation
Use the arrow keys to move between data points, Home and End to jump to the first and last.
import { Sankey } from '@reactloom/charts';
const nodes = [
{ id: 'budget', label: 'Budget' },
{ id: 'product', label: 'Product' },
{ id: 'sales', label: 'Sales' },
{ id: 'people', label: 'People' },
{ id: 'tools', label: 'Tools' },
{ id: 'events', label: 'Events' },
];
const links = [
{ source: 'budget', target: 'product', value: 600 },
{ source: 'budget', target: 'sales', value: 400 },
{ source: 'product', target: 'people', value: 450 },
{ source: 'product', target: 'tools', value: 150 },
{ source: 'sales', target: 'people', value: 250 },
{ source: 'sales', target: 'events', value: 150 },
];
export default function Example() {
return <Sankey title="Budget allocation (k€)" nodes={nodes} links={links} />;
}Visitor journeys
Use the arrow keys to move between data points, Home and End to jump to the first and last.
| Search | Home page | 5,200 |
|---|---|---|
| Search | Pricing | 1,800 |
| Social | Home page | 2,400 |
| Home page | Pricing | 2,100 |
| Pricing | Sign-up | 1,300 |
import { Sankey } from '@reactloom/charts';
const nodes = [
{ id: 'search', label: 'Search' },
{ id: 'social', label: 'Social' },
{ id: 'home', label: 'Home page' },
{ id: 'pricing', label: 'Pricing' },
{ id: 'signup', label: 'Sign-up' },
];
const links = [
{ source: 'search', target: 'home', value: 5200 },
{ source: 'search', target: 'pricing', value: 1800 },
{ source: 'social', target: 'home', value: 2400 },
{ source: 'home', target: 'pricing', value: 2100 },
{ source: 'pricing', target: 'signup', value: 1300 },
];
export default function Example() {
return <Sankey title="Visitor journeys" nodes={nodes} links={links} table="visible" />;
}API reference
| Prop | Type | Default |
|---|---|---|
nodesrequired | { id, label }[] | — |
linksrequired | { source, target, value }[] | — |
titlerequiredNames the figure. | string | — |
descriptionThe takeaway; a factual summary is generated when omitted. | ReactNode | — |
tableThe data table alternative. | 'toggle' | 'visible' | 'none' | 'toggle' |
height · valueFormat · formatValue · messagesAs on the other charts. | | — |
Customization
Extracted from the component’s source on every build, so it matches the code. How the layers fit together is explained in Customization.
State attributes
Target these in your CSS to style states without depending on class names.
| Attribute | Values |
|---|---|
[data-active] | present when on |
Theme tokens it reads
--pl-color-fg-muted
Accessibility
- The chart is a figure named by its title and described by a summary; the drawing is hidden from assistive technology.
- The plot is one tab stop: arrow keys move between items and each is announced; the data table gives every value.
- Flows are read as “from to to: value (share)”; the table lists every flow.
| Key | Action |
|---|---|
| ← → ↑ ↓ | Move between flows |
| Home / End | First / last flow |
Usage guidelines
Do
- Keep to a handful of stages.
Don’t
- Don't draw cycles: flows go one way.