API: primitives (@fragiola/flow-react, @fragiola/flow-vue, @fragiola/flow-svelte, @fragiola/flow-angular)
ToggleInteractive
Flow.ToggleInteractive is a toggle button that locks the flow, turning dragging, connecting and selecting off while pan and zoom keep working.
Flow.ToggleInteractive renders a button (type="button") that locks and unlocks the flow
the way React Flow's interactive button does: locking runs "set-interactive" with { drag: false, connect: false, select: false } (no drag, no connection, no selection, nor their keys),
unlocking with those three and interactive on. Pan and zoom keep working, and so do resizing and
the delete keys (the root's interactive={false} stops those too). It is locked, aria-pressed,
while none of the three kinds is allowed (engine.is("interactive-by", { kind }), or the flow is
not interactive), and carries data-interactive while unlocked; it is disabled until the root is mounted. A disabled of yours replaces that rule (your props win), unlike the zoom and fit buttons, which stay disabled while their action is refused whatever you pass. It sets no text: switch its icon on
state.interactive and give it an aria-label.
import { LockIcon, UnlockIcon } from "lucide-react";
<Flow.ToggleInteractive
aria-label="Lock the flow"
render={(props, state) => <button {...props}>{state.interactive ? <UnlockIcon /> : <LockIcon />}</button>}
/>;The root's interactive prop locks the whole flow from your state (the toggle then shows locked,
and a click unlocks it whole); a root whose interactive does not change leaves the toggle's lock
alone.
One kind switches alone from a toggle of yours: engine.run("set-interactive", { drag, connect, select, reconnect }) sets the switches it names and keeps the others, and every gesture reads
them when it acts (moving an edge's end needs connect too). A node's or an edge's own flags
(draggable, connectable, selectable, reconnectable,
Nodes and edges) still apply under them.
Props
ToggleInteractiveProps extends the common primitive props
and every button attribute.
| prop | type | default | description |
|---|---|---|---|
children | ReactNode | none | its icon or label |
State
ToggleInteractiveState, what className, style and render receive:
| field | type | description |
|---|---|---|
interactive | boolean | the flow is not locked: it is interactive and dragging, connecting or selecting is on |
Data attributes
| attribute | value |
|---|---|
data-flow-part | "toggle-interactive" |
data-interactive | present while the flow is unlocked |
aria-pressed | true while the flow is locked |