Workflow Canvas
ProNewA canvas for building a conversation flow: say, listen, condition, tool, transfer and end steps that drag and snap, connections drawn from port to step, pan, pinch and fit, and a run that lights its path as it goes.
Installation
pnpm dlx shadcn@latest add @viewport/workflow-canvas
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
The code behind the preview above comes with Truffle Pro.
Props
| Prop | Type | Default |
|---|---|---|
| nodes* | WorkflowNode[] | — |
| edges* | WorkflowEdge[] | — |
| onNodesChange | (nodes: WorkflowNode[]) => voidCalled as steps are dragged, nudged or deleted. Leave it out for a read-only canvas. | — |
| onEdgesChange | (edges: WorkflowEdge[]) => voidCalled when a connection is drawn or removed. | — |
| selected | string | nullThe id of the selected step. | — |
| onSelectedChange | (id: string | null) => void | — |
| path | string[]The steps a run has passed through, in order. They and the connections between them are lit, and the last one pulses while `running`. | [] |
| running | boolean | false |
| accent | stringThe color of a run. | "oklch(0.68 0.14 235)" |
| label | stringAccessible name of the canvas. | "Workflow" |
| className | string | — |
Accessibility
- Steps are buttons named with their kind and where each way out leads.
- Arrow keys nudge the selected step; Delete removes it; each connection has its own remove button.
- The whole flow is repeated as a list for screen readers.
- Drawing a connection needs a pointer, so pair it with a form that sets the next step.
- Entrances, the fit transition and the moving connection are off under reduced motion.