@beehexa/vueflow-tokens adapts the authoritative tokens to VueFlow 1. It does not copy
VueFlow source, bundle Vue, generate graph data, or change relationship direction.
Install and apply
Install this package, @beehexa/design-tokens, Vue 3, and the VueFlow 1 core, controls and
minimap peers. Load upstream core, theme, controls and minimap CSS in the lazy graph
entry before adapter CSS; load native design-token CSS once with a 16px root/14px body.
Local source packages remain private 0.0.0; that is not a registry release.
<script setup lang="ts">
import { computed } from 'vue'
import { VueFlow } from '@vue-flow/core'
import { Background } from '@vue-flow/background'
import { Controls } from '@vue-flow/controls'
import { MiniMap } from '@vue-flow/minimap'
import { createVueFlowTheme } from '@beehexa/vueflow-tokens'
import '@beehexa/design-tokens/css'
import '@vue-flow/core/dist/style.css'
import '@vue-flow/core/dist/theme-default.css'
import '@vue-flow/controls/dist/style.css'
import '@vue-flow/minimap/dist/style.css'
import '@beehexa/vueflow-tokens/css'
const props = defineProps<{ dark: boolean; locale: 'en' | 'vi' }>()
const theme = computed(() => createVueFlowTheme(props))
// nodes and edges remain application graph data; never recreate their IDs on theme changes.
</script>
<template>
<VueFlow :class="theme.class" :style="theme.style" v-bind="theme.flowOptions">
<Background v-bind="theme.background" />
<Controls />
<MiniMap v-bind="theme.minimap" />
</VueFlow>
</template>
The factory returns scoped variables, viewport bindings typed with FlowProps (not deprecated FlowOptions), and Background/MiniMap bindings.
It resolves light plus dark overrides and Vietnamese typography alternatives from the token
package. Recompute when theme or locale changes. Keep ready/error handlers and fit the graph
with padding 0.2 when the host becomes measurable or changes size. VueFlow 1’s actual
fitViewOnInit option is used; do not pass invented viewport option names.
Colour tones are not statuses
FlowTone (FLOW_TONES) names eight generic colour tones: blue, red, green,
crimson, yellow, teal, magenta and purple. Each reads one existing foundation
flow.category.* role set; the foundation keys keep their names, and the package gives a
tone no meaning. The consumer decides which of its own node or relation kinds takes which
tone. A tone must not be interpreted as success, failure or warning. Keep the node’s kind
label and icon; colour is never its sole identity, and a tone does not certify the state of
an execution.
Each tone supplies foreground, background, border and hover as an opaque paired
light/dark role. Use getFlowTonePalette(tone) for CSS-backed bindings; its border is
the frame/edge identity. These source roles replace historical application-owned palettes,
alpha overlays, gradients and palette-adjustment functions. Never append hex alpha suffixes
to a CSS variable, or lighten a resolved role downstream.
For a native kind Tag, bind getFlowToneBadgeStyles(tone) to the public style prop and
omit color. This cached immutable recipe pairs the tone foreground/background/border
instead of putting native white text on a frame/edge stroke. The canonical contrast check
includes all eight small-text pairs in both themes at WCAG AA 4.5:1; the native family
demonstrates their actual paint. The teal foreground and border remain separate roles.
Selection uses color.border.selected plus the selected outline; keyboard focus separately
uses color.border.focus, the focused border width and state.focus.offset. Errors use the
danger frame plus dashed/non-colour indication and a readable error label. Selection or focus
must not overwrite tone identity, hide an error, or be conveyed only through colour.
Resting handles use the neutral icon role. Focus color is reserved for actual focus,
not an always-on connector decoration.
Native WorkflowViewer anatomy
Keep the actual WorkflowViewer / WorkflowNodeCard and provide its public
NodeLook: title, subtitle, kind, caption, category icon, source/destination
logos, domain indicators and optional typed execution. The Source companion
.bh-workflow-canvas binds those existing slots to complete Source roles:
font.heading.xsmall for the fully wrapped title, font.body.default for the
description and font.body.small for kind, caption and indicators. The fixed
neutral category tile is not a run-state badge. Do not replace a rich native
node with its ID or a plain rectangle in order to apply tokens.
Native stadium nodes grow to their content’s intrinsic width within the existing
native minimum and maximum. Short terminal titles remain whole beside their category
glyph and optional execution marker. Keep the native maximum; do not remove a marker,
clip a title or add consumer-specific terminal widths.
Ordinary cards can explicitly opt into NodeLook.sizing: 'content'. The native
canvas owns only the width mechanism: the box grows to content between
--wf-node-content-min-width and --wf-node-content-max-width. The Source
companion owns those roles (diagram.card.width and twice that role) and the whole
presentation recipe: title/kind wrap, the growing head and every source/destination
logo kept within the card. No declaration is defined in both stylesheets. No fixed-width
increase applies to other consumers; stadium, diamond and ellipse cards ignore the opt-in.
Keep all logos; do not supply guessed geometry or patch card internals downstream.
Native WorkflowEdge.tone is orthogonal to variant. Use blue, red or green:
Source binds --wf-edge-tone-<tone> to the existing foundation border roles
--bh-flow-category-task-border, --bh-flow-category-dependency-border and
--bh-flow-category-transformation-border in the current theme (foundation names
unchanged), with static solid, short-dash and dash-dot cues. The consumer maps its own
relation kinds onto these tones. Do not use failure to colour a relation. The native
renderer validates tokens, retains tone ink/cues under hover, selection, trace, failure,
possible and context, and carries them to arrowheads and jump swatches. PNG export reuses
the native exporter’s DOM/stylesheet serialization, with no tone-specific path. Omitted tone
preserves existing edge behavior.
Relation certainty, context and failure are shape cues, never a new dash pattern, a colour change of the tone or an opacity reduction, so each tone dash stays unique (WCAG 1.4.1/1.4.11):
- Possible (
certainty: 'possible', a dynamic-route candidate or SWITCH case): a hollow mini-diamond at the source end, the BPMN 2.0 conditional-flow marker. - Context (
context: true, retained breadcrumb context): a UML-style open arrowhead and the thinner resting stroke--wf-edge-context-width, a package-owned variable bound to the foundationborder.width.default; highlight widens it as usual. - Toned failure (
variant: 'failure'with a tone): tone ink and tone dash, plus the LucideCircleXmark painted withcolor.icon.danger(--wf-edge-failure-icon) beside the edge label. The mark is decorative (aria-hidden); jump names and the legend keep the words. An untoned failure keeps the failure ink and5 4dash.
Possible and context may combine. Pass the localized group name as familyLabel:
jump chips and lists are then named {family} jump to {target}, numbered (n of m)
when parallel jumps would share a name. Localize the whole name, numbering and list
titles through the viewer’s texts.jumps (WorkflowJumpTexts), keeping the group word
first; a localized group inside the English default is not a localized name. Sources:
packages/vueflow-tokens/src/styles.css and the native workflow-canvas edge.
These source bindings do not prove appearance: manually check both themes, many logos,
long titles, parallel tones, possible/context/failure marks, trace/hover/fullscreen
and exported PNG.
Group frames. A native group (WorkflowNode.group, the built-in wf-group node) is
the node’s card as a header with a round expand/collapse toggle; expanded, its children sit
inside a frame below the header. The companion binds the frame to the package-owned
--wf-group-* variables, each over an existing foundation role: border color.border,
border width border.width.default, radius radius.card, fill color.surface.subtle
and, for a frame inside a frame, color.background.neutral, so the levels read apart;
padding space.stack and header gap space.150. No flow-specific foundation token backs
them. The native layout reads --wf-group-padding and
--wf-group-header-gap from the canvas, so keep both plain lengths. High contrast draws
the frame border in text ink. A frame is a container, never a tone or a run state:
do not tint it by tone or status.
Selection box. Shift + drag on the empty native canvas draws a box that selects the
cards it touches (an expanded frame only when fully inside). The companion binds it to the
same selection recipe as .bh-vue-flow .vue-flow__selection: a transparent box (no fill, so
the swept cards stay visible) with a dashed border.width.selected border in
color.border.focus, in light and dark. A selection keeps the node selection ring; the box
is never a tone or run-state cue.
Find box. The native viewer’s find box (/ or the dock’s Search) is an overlay with a
search field and result rows. The companion binds its --wf-find-* and the shared --wf-list-*
roles: color.surface.overlay, elevation.shadow.overlay and radius.overlay, with no border
(an overlay is set apart by its surface and shadow) and a color.border divider under the field.
The field and the empty state use font.body.default, the placeholder color.text.subtlest
and the empty state color.text.subtle. A row uses font.label.default for the node’s name,
space.075 / space.item.x padding, at least size.control.default high (size.target.touch
on coarse pointers and below 768 px) and radius.item; the kind label after the name is
font.body.small in color.text.subtle, and a node without a name shows its id in
font.code.default. Names wrap at word boundaries and are never truncated; only a single word
wider than the row breaks. Rows take the overlay item states one step apart: the row under the
pointer color.surface.overlay.hover; the keyboard-active row color.surface.overlay.selected
with the border.width.selected start bar in color.border.selected as its non-colour cue;
that row hovered color.surface.overlay.selected.hover. Text keeps its colour in every state;
each pair is in the checked contrast list. Focus is the field’s ring around the whole box
(border.width.focused, color.border.focus, state.focus.offset). While a row is under the
pointer or reached with ↓ / ↑, the canvas previews its node with the existing hover state and
the node’s outer ring (diagram.selection-ring); it ends when the pointer leaves the list, the
query changes or the box closes, and never changes the selection, the trace or the viewport (an
off-screen node is not panned to). Do not restyle the box per viewer.
Diamond and ellipse titles and kind captions wrap at word boundaries and are never truncated: their side padding follows their width, so a mid-word break would read as two words and an ellipsis would hide the node’s own name. Only a single word wider than the content box breaks. Ordinary cards may still break a long unbroken title anywhere.
NodeLook.execution is absent for definitions. Typed states retain their
diagram.* fill/stroke/text pairs and native non-colour marker; the not-taken
boundary is dashed. Selection, hover and keyboard focus stay on independent
outer-ring geometry, so a selected failed node remains visibly failed.
Repetition, logos and group disclosure remain domain metadata.
Log-derived node readings reached (a legacy log says the step ran, no typed outcome) and
unfinished (started, no recorded end) are not typed run outcomes. The companion paints them
with diagram.log-reached / diagram.log-unfinished as outline and marker ink
(--wf-node-state-ink); nodes keep an independent selection ring, so node reached keeps the
log role. unfinished leaves the node’s own fill and text (including high-contrast overrides)
and dashes both the outline and the subroutine edge 4 3. --wf-node-execution-outline-width
binds border.width.focused for ranOk, ranFailed, reached and unfinished, as Mermaid
draws them; neverReached / branchNotTaken keep the native default.
Never present either reading as ranOk or ranFailed.
Edge run evidence WorkflowEdge.execution (reached, unfinished, failed, notTaken) is
distinct from the authored failure route (variant: 'failure') and from tone. Source binds:
reachedtocolor.text, notdiagram.log-reached: that role and the edge highlight (--wf-edge-active,diagram.selection-ring) are the same blue, so a resting walked edge would look selected. Its non-colour cue is the bold--wf-edge-execution-width(border.width.focused), like Mermaid’s neutral walked edge.unfinishedtodiagram.log-unfinished, dashed4 3.failedtodiagram.fail-stroke, with the circle-x failure mark.notTaken(a declined route) todiagram.nottaken-strokeat the ordinary width, dashed6 3.
--wf-edge-execution-width must be a CSS length. Execution ink wins over tone ink; the
unfinished / notTaken dash wins over tone and failure dashes, and a displaced authored
failure keeps its circle-x mark. The legend names each present reading and edge accessible
names append it (Edge from A to B, run failed). In high contrast reached shares the edge ink
(color.text) and is distinguished by width; the other readings keep their theme-resolved inks.
The real native live demo belongs to the
workflow-canvas producer playground,
not a replacement renderer embedded here. In that checkout run
npm ci && npm run playground -- --host 127.0.0.1 --port 5174 and open
http://127.0.0.1:5174/?anatomy. It reuses the existing nine-node credential,
38-node RPA and loop fixtures with theme/language controls, explicit sample
typed execution, long title/metadata, native ports, selection and native PNG
export. Build Source packages first and prepend HEXASYNC_LOCAL_PACKAGES=1
to verify unpublished adapter anatomy from built public exports. Default
playground installs remain registry-only; Source site CI needs no access to
the private native canvas package. The Mermaid demonstration
runs here using its public native model and the same Source anatomy roles.
Routing stays in the native canvas. Unpinned edges select attachment sides from the current measured layout; authored source/target pins remain authoritative. After dragging a task or expanding a group, do not repin every edge to one side or resurrect a downstream layout processor to hide an attachment defect.
Custom content and geometry
Use getFlowNodeStyles({ tone, width, height, shape? }, state) for custom node bodies.
It binds semantic fonts, spacing, the tone pair and the consumer-owned dimensions;
shape: 'circle' rounds the body fully and state.dashed dashes its border. Keep custom
icons, logos, labels, handles, accessibility semantics and events in the application.
Meaningful loading indicators may move; decorative node entrances, pulsing identities,
rotating idle icons, hover transforms, flowing edge dashes, gradients and glass are not part
of the theme.
Custom tone content uses getFlowToneStyles(tone, part?);
foreground sets tone text, border sets border colour and background
sets its paired surface. Tone glyphs use getFlowIconStyles(tone, options),
whose default colour is the tone border, not text. Options accept source icon
size names or numeric API sizes, an already source-resolved colour, and disabled.
Status icon keys (status-success|warning|error|info|loading) and control keys
(control-expand|collapse|help) resolve separate operational/neutral icon roles.
bh-flow-icon[data-bh-loading="true"] supplies meaningful loading motion with
reduced-motion support. Never animate an idle kind icon.
For a labelled relationship indicator use bh-flow-tone-mark and
data-bh-tone="<FlowTone>": the source owns its space.075 circular
geometry and tone border-colour fill (blue when unset). A label/count must preserve the
non-colour meaning; this mark does not communicate execution status.
The package ships no node-size, grid or layout tables: node geometry belongs to the consumer, and rendering, layout and half-dimension centering must read the same consumer source. Preserve existing graph coordinates during theme adoption.
Graph layout coordinates, intrinsic sizing, flex/grid mechanics and viewport transforms are not palette values. Do not arbitrarily round them to the spacing scale. Tone adaptation must not mutate the graph’s IDs, expansion state, saved positions or relationship semantics.
Ordinary node bodies, MiniMap cards and Controls frames use radius.100 (8 px).
Their actual control buttons use radius.050 (4 px), without clipping focus;
4 px frame padding nests those control corners inside the 8 px frame. Node
logos retain their nested radius.075 (6 px). Circular nodes keep their
true circular geometry, as do connection handles; edge-routing radius remains
path geometry. Inspector cards remain 8 px and dialogs/drawers use
radius.150 (12 px). The native WorkflowDock shares this compact frame/control
family and floats inside the viewport, default lower-left, outside camera
transforms; never replace it with a full-width toolbar band. Text-editor headers
remain intrinsic document chrome. Follow the Radius role scale.
The native dock’s zoom-menu surface uses radius.overlay (8 px), independently
of compact Buttons and menu items; do not derive it from a button radius plus
a fixed pixel offset. Keep native MiniMap/legend surfaces at
radius.100 and the actual keyboard-shortcuts Dialog at radius.150; its close
Button still uses radius.050. These role bindings belong to the Source companion,
not per-viewer CSS or a global chrome-radius change.
Bind the user’s high-contrast setting to data-bh-high-contrast="true" on the actual
bh-vue-flow host. The companion CSS widens node/edge/path, button and custom
role="button" focus outlines from border.width.focused (2 px) to
border.width.accent (4 px), preserving source focus colour/offset. Do not keep
an application-owned descendant focus recipe.
The same host accepts data-bh-large-text="true" and
data-bh-increased-spacing="true" for the user’s opt-in accessibility settings:
1.125em node text, and 1.6 line-height / 0.02em letter-spacing respectively.
Keep actual user preference bindings; do not duplicate descendant CSS locally.
Native WorkflowViewer consumers use .bh-workflow-canvas with
data-bh-contrast="high". Its companion recipe strengthens node boundaries,
descriptive text, edges and arrowheads with theme-resolved strong text ink.
Selection and error paint retain their separate meanings; focus uses the accent
outline width. Removing the attribute restores the base recipe, and changing
theme while enabled resolves the new theme’s ink without remounting the graph.
Keep navigator and accessibility actions in the viewer’s native #dock extension
slot alongside its built-in controls rather than replacing the dock.
Edges, controls and export
styleTargetEdge(edge, nodes, toneOf?) preserves the directed edge’s target identity on
both stroke and marker from the target node’s tone (toneOf(node), blue when omitted or
when the target is missing), keeps other edge data, and disables decorative traversal
motion. The application may retain dashed lines to communicate its own relation semantics.
The custom edge renderer must consume the supplied stroke rather than replace it with an
unrelated edge palette. FLOW_EDGE centralizes widths, marker size, path radius and handle
size.
Custom edge paths use getFlowEdgeStyles(tone, suppliedStyle?) for the full
SVG presentation recipe. It preserves a supplied directed target stroke over the
tone fallback and a supplied static dash, and uses FLOW_EDGE.width, no fill and a
non-scaling stroke; the consumer owns what a dash means.
Path coordinates, marker shapes and relationship direction remain graph geometry.
Edge styles and node container styles use VueFlow’s public Styles type, including
custom theme variables. Detail simplification accepts and returns that same native
contract; applications do not need casts or copied style objects to assign it.
styleTargetEdge retains an explicit open/closed arrow kind.
createVueFlowTheme({ nodeTone }) colours MiniMap nodes the same way (blue by default).
The CSS companion addresses actual VueFlow core/default nodes, handles, edge labels, selection, Controls buttons and MiniMap surfaces. Controls preserve normal, hover, disabled and focus states and enlarge to source touch targets for coarse pointers. Import it after upstream CSS; remove competing consumer-wide core/controls/minimap paint rules rather than escalating specificity.
Export the current theme and font from the measured graph surface. Do not force a white background or independent system-font palette. Preserve snapshot/fit/restore, overlay filtering, resolution feedback and capture fallback handling. Check the real exported image, not just a successful capture call.
Graph fullscreen uses an isolated local stacking context at z-index.modal (400), like
other fullscreen surfaces, so global inspectors opened from it stay above it. Private child chrome
ordering such as z10/z15 stays inside that context; do not assign global1001/1002
to graph controls. Verify real inspector/dialog ordering, Escape and focus return.
getFlowDetailStyles(level, suppliedStyle) removes shadow at minimal detail;
basic and detailed return the supplied style unchanged. It never reduces opacity:
node state, text contrast, focus and tone semantics must remain readable at
every zoom level. Viewport thresholds, metadata, measured positions and scheduling
remain consumer logic; no nodes, relationships or data fields may be discarded.
Verification
Exercise light and dark, English and Vietnamese, selected plus focused and error nodes, long labels, consumer-owned dimensions, target-coloured arrows, zoom/snap/fitting, expanded groups, cycles, narrow and fullscreen hosts, ESC exit, Controls, MiniMap and export. Calculate contrast for the actual paired foreground/background and meaningful borders in each rendered theme; source tokens and typed configuration alone are not accessibility or visual proof.