Hulian UIv0.93.5413 components0 components
  • Start
  • Components
  • Blocks
  • Pages
  • Demos
  • Changelog
ChineseEnglish
  • ComponentsComponents
  • ThemeTheme

Collections

  • QuestionCard
  • Table
  • Book3D
  • ProTable
  • PricingTable
  • JsonViewer
  • EditableTable
  • List
  • Descriptions
  • RowActions
  • Tree
  • Card
  • Carousel
  • Video
  • Audio
  • BentoGrid
  • Image
  • MagicCard
  • AnimatedList
  • Marquee
  • Sortable
  • Kanban
  • DesignCanvas
  • LayerTree
  • StageDraw
  • SlideDeck
  • PresenterView
  • ComponentPicker
  • EventStream
  • QueueLane
  • DocumentSheet
  • Novel reader
  • Scheduler
  • Org classroom
  • Danmaku
  • LiveChat
  • LivePlayer
  • LogViewer
  • FileTree
  • CodeReviewThread
  • VirtualList
  • InfiniteScroll
  • LogoLoop
  • BounceCards
  • CardSwap
  • ChromaGrid
  • CircularGallery
  • DomeGallery
  • FlyingPosters
  • InfiniteMenu
  • MagicBento
  • ScrollStack
  • ProfileCard
  • TiltedCard
  • PixelCard
  • DecayCard
  • ReflectiveCard
  • Folder

Charts and Diagrams

  • Flow
  • Diagram
  • Paper
  • SequenceDiagram
  • Sankey
  • Sparkline
  • Funnel
  • Treemap
  • Gantt
  • Heatmap
  • ContributionGraph
  • Legend
  • Chart
  • WorldMap

Information

  • ImageViewer
  • LiveProductCard
  • DiffStat
  • ScoreRing
  • ScoreScale
  • Badge
  • Dot
  • StatusDot
  • Chip
  • FilterChip
  • Coupon
  • Tag
  • Annotation
  • Avatar
  • AvatarCircles
  • User
  • QRCode
  • Comment
  • RelativeTime
  • GitCommit
  • DeployStatus
  • ShieldBadge
  • AwardBadge
  • CreditCard
  • IconTile

Metrics

  • Stat
  • Statistic
  • Meter
  • Timeline
  • NumberTicker

Placeholders

  • Empty
  • Skeleton
  • Watermark

Flow

flow

Edits controlled node-and-edge canvases with node dragging, edge connection, panning, zooming, and fit view.

Usage

Basic node canvas

Controlled nodes/edges; getHandles declares the connection stubs for each node (left target in / right source out). Drag the node to change the position, drag the line from the output pile to the input pile, scroll wheel translation, Ctrl+wheel zoom.

Prompt word
Cyberpunk city night scene
Raw graph model
SDXL · 30 steps
HD zoom
×2 · Facial Restoration
Output
1 picture
tsx
const [nodes, setNodes] = useState(initialNodes);
const [edges, setEdges] = useState(initialEdges);

<Flow
  nodes={nodes}
  edges={edges}
  getHandles={(n) => [
    ...(n.data.io.includes("in") ? [{ id: "in", type: "target" as const }] : []),
    ...(n.data.io.includes("out") ? [{ id: "out", type: "source" as const }] : []),
  ]}
  onNodesChange={setNodes}
  onConnect={(c) => setEdges((e) => [...e, { id: uid(), ...c }])}
  renderNode={(n) => <NodeCard data={n.data} />}
/>

Edge labels

FlowEdge.label is optional. Long copy wraps inside the documentation column, and each short label sits on its own edge. An edge without a label stays as it was. The name sits outside the aria-hidden edge layer so a screen reader can read it. Per-edge keyboard selection is not part of this step. A label on a crossing edge can still sit against a neighbor; this step does not add general collision avoidance.

Split
Three outputs
Queue
Pending
Exception
Pending
Alarm
Exception
audit
Trace
Trace
Pending
Collection
Raw events
Archive
Searchable
tsx
<Flow
  nodes={nodes}
  edges={[
    { id: "e1", source: "ingest", target: "archive", label: "Normalize raw events into a searchable archive" },
    { id: "e2", source: "router", target: "queue", label: "Enqueue" },
    { id: "e3", source: "router", target: "alert" },
  ]}
  getHandles={getHandles}
  renderNode={(n) => <NodeCard data={n.data} />}
/>

Comparison, fan-out, and crossing

The same nodes and edges are shown three times: no label, a blank label, and visible text. The labeled copy is a shared-source fan, two crossing curves, two adjacent edges, and one long label. A short label at a crossing can still sit against the neighboring edge; this step does not guarantee they are separated.

Same data, with labels

Fan out
Upper branch
Middle branch
Lower branch
West
East
South
North
Near upper
Near upper end
Near lower
Near lower end
Collection
Archive

Same data, no label

Fan out
Upper branch
Middle branch
Lower branch
West
East
South
North
Near upper
Near upper end
Near lower
Near lower end
Collection
Archive

Same data, blank label

Fan out
Upper branch
Middle branch
Lower branch
West
East
South
North
Near upper
Near upper end
Near lower
Near lower end
Collection
Archive
tsx
<Flow
  nodes={nodes}
  edges={labeled}
  getHandles={getHandles}
  renderNode={(n) => <NodeCard data={n.data} />}
/>
<Flow nodes={nodes} edges={unlabeled} getHandles={getHandles} renderNode={(n) => <NodeCard data={n.data} />} />
<Flow nodes={nodes} edges={blankLabels} getHandles={getHandles} renderNode={(n) => <NodeCard data={n.data} />} />

Select and delete

selectedId / onSelectNode Controlled radio selection: click on the node to select, click on the blank to cancel. After selecting, click × or press Delete to delete the node (and delete its connections as well).

Prompt word
Cyberpunk city night scene
Raw graph model
SDXL · 30 steps
HD zoom
×2 · Facial Restoration
Output
1 picture
tsx
<Flow
  nodes={nodes}
  edges={edges}
  getHandles={getHandles}
  selectedId={selected}
  onSelectNode={setSelected}
  onNodeDelete={(id) => {
    setNodes((p) => p.filter((n) => n.id !== id));
    setEdges((p) => p.filter((e) => e.source !== id && e.target !== id));
    setSelected(null);
  }}
  onEdgesDelete={(ids) => setEdges((p) => p.filter((e) => !ids.includes(e.id)))}
  renderNode={(n) => <NodeCard data={n.data} />}
/>

Running (connected to streamer)

isEdgeAnimated returns the connection flow animation of true, which is often used to mark the link being executed.

Prompt word
Cyberpunk city night scene
Raw graph model
SDXL · 30 steps
HD zoom
×2 · Facial Restoration
Output
1 picture
tsx
<Flow
  nodes={nodes}
  edges={edges}
  getHandles={getHandles}
  isEdgeAnimated={() => true}
  renderNode={(n) => <NodeCard data={n.data} />}
/>

Hide zoom control bar

controls={false} Turn off the zoom/fit toolbar in the lower right corner, suitable for pure display scenarios.

Prompt word
Cyberpunk city night scene
Raw graph model
SDXL · 30 steps
HD zoom
×2 · Facial Restoration
Output
1 picture
tsx
<Flow
  nodes={nodes}
  edges={edges}
  getHandles={getHandles}
  controls={false}
  renderNode={(n) => <NodeCard data={n.data} />}
/>

When to use

Use Flow to build a visual AI workflow, process, or DAG editor with controlled nodes and edges. Use Kanban for cards moving between columns or Sortable for one reorderable list.

Import

ts
import { Flow, bezierPath, clampZoom, fitViewport, handleOffsetRatio, handlePoint, nodesBounds, screenToCanvas, zoomAtPoint } from "@hulianui/ui"

Props

FlowProps<T> is generic.

NameTypeDefaultDescription
nodes *FlowNode\<T\>[]-Controlled { id, position, data, width? } nodes.
edges *FlowEdge[]-Controlled { id, source, target, sourceHandle?, targetHandle?, label? } edges. label is optional; see Edge labels.
getHandles *(node: FlowNode\<T\>) => FlowHandleSpec[]-Declares left target and right source handles, distributed vertically in return order.
selectedIdstring | null-Controlled selected node id.
defaultNodeWidthnumber240Default node width in canvas pixels.
minZoomnumber0.35Minimum zoom.
maxZoomnumber2Maximum zoom.
controlsbooleantrueShows zoom and fit controls.
isEdgeAnimated(edge: FlowEdge) => boolean-Enables flow animation for selected edges.
classNamestring-Canvas wrapper class; it must establish a height.
apiRefMutableRefObject\<FlowApi | null\>-Exposes fitView, zoomIn, zoomOut, reset, and autoLayout.

Events

EventTypeDescription
onNodesChange(nodes: FlowNode\<T\>[]) => voidReturns all node positions after a drag.
onConnect(connection: FlowConnection) => voidReports a valid output-to-input connection without an id.
onEdgesDelete(ids: string[]) => voidRequests deletion of selected edges.
onNodeDelete(id: string) => voidRequests deletion of the selected node.
onSelectNode(id: string | null) => voidReports node or blank-canvas selection.

Slots

SlotTypeDescription
renderNode *(node: FlowNode\<T\>, state: { selected: boolean }) => ReactNodeRenders node content while Flow owns the frame, handles, and selected state.
backgroundReactNode | falseCanvas background; false disables the built-in dot grid.

Example

tsx
const [nodes, setNodes] = useState(initialNodes);
const [edges, setEdges] = useState(initialEdges);
const [selected, setSelected] = useState<string | null>(null);

<div className="h-[420px] w-full overflow-hidden rounded border border-border">
  <Flow<NodeData>
    nodes={nodes}
    edges={edges}
    getHandles={getHandles}
    selectedId={selected}
    onSelectNode={setSelected}
    onNodesChange={setNodes}
    onConnect={(c) => setEdges((p) => [...p, { id: `e${Date.now()}`, ...c }])}
    onEdgesDelete={(ids) => setEdges((p) => p.filter((e) => !ids.includes(e.id)))}
    onNodeDelete={(id) => {
      setNodes((p) => p.filter((n) => n.id !== id));
      setEdges((p) => p.filter((e) => e.source !== id && e.target !== id));
    }}
    renderNode={(n) => <div className="px-3.5 py-2.5">{n.data.title}</div>}
  />
</div>

Edge labels

FlowEdge.label is optional. Omit it, or pass only whitespace, and that edge draws no label. Pointer interaction, deletion, and the accessibility tree stay the same as an edge without the field.

tsx
{ id: "e1", source: "prompt", target: "model", label: "Prompt" }

When the text is present, the chip sits on the outside of its own bezier, off the midpoint, and a short leader joins it back to that point on the curve. It uses the surface background and foreground text, the same tokens as nodes and the delete button. Long text wraps at a maximum of 10rem. It is not truncated and it does not turn into an ellipsis. A short edge does not collapse the text into a few characters per line; the chip moves clear of the endpoint nodes and ports instead.

The box stays off both connector ports and off the delete button that appears at the midpoint of a selected edge. Placement looks only at that edge's own endpoints. Crossing, coincident, or tightly packed edges are not separated from each other, so their labels can still overlap.

The path is drawn in an aria-hidden SVG, which means text inside that layer is not exposed to assistive technology. The label is a group outside that layer, and the group's accessible name is the label text. The visible characters are aria-hidden so the name is not announced twice. This slice exposes the name only. It does not add per-edge keyboard selection, deletion, or focus restoration.

Usage notes

  • The outer element must have a definite height or the canvas is invisible.
  • label is optional. When it is omitted or blank, the edge draws no label, and pointer, delete, and screen-reader behavior match an edge without the field.
  • A label sits on the outside of its own curve, off the crossing, and a short leader joins the chip back to that curve. It stays clear of both connector ports, both endpoint nodes, and the selected edge's delete button. Long text wraps at a maximum of 10rem instead of collapsing to a few characters when the edge is short. Labels do not avoid each other: the chips can still stack.
  • Edge paths live in an aria-hidden SVG. The label name is outside that layer, so assistive technology can read the text. This slice does not add per-edge keyboard selection, deletion, or focus restoration.
  • Flow is fully controlled. Add ids and deduplicate new connections; when deleting a node, also remove its incident edges.
  • Pointer Events make Flow client-only.
  • The similarly named navigation-menu layout note concerns Base UI and does not apply here.
  • Built-in Chinese accessibility labels are "\u5de5\u4f5c\u6d41\u753b\u5e03" (“Workflow canvas”), "\u5220\u9664\u8fde\u7ebf" (“Delete edge”), "\u653e\u5927" / "\u7f29\u5c0f" (“Zoom in” / “Zoom out”), "\u9002\u914d\u89c6\u56fe" (“Fit view”), "\u667a\u80fd\u6392\u7248" (“Auto layout”), "\u5de5\u4f5c\u6d41\u8282\u70b9" (“Workflow node”), "\u5220\u9664\u8282\u70b9" (“Delete node”), and fallback handle labels "\u8f93\u51fa" / "\u8f93\u5165" (“Output” / “Input”).

Related

Table · Book3D · ProTable · PricingTable · JsonViewer · EditableTable

Playground

Prompt word
Cyberpunk city night scene
Raw graph model
SDXL · 30 steps
HD zoom
×2 · Facial Restoration
Output
1 picture
<Flow
  nodes={nodes}
  edges={edges}
  getHandles={(n) => [{ id: "in", type: "target" }, { id: "out", type: "source" }]}
  onNodesChange={setNodes}
  onConnect={(c) => setEdges((e) => [...e, { id: uid(), ...c }])}
  renderNode={(n) => <NodeCard data={n.data} />}
/>
PreviousKanbanData DisplayNextDiagram

On this page

  • Usage
  • Documentation
    • When to use
    • Import
    • Props
    • Events
    • Slots
    • Example
    • Edge labels
    • Usage notes
    • Related
  • Playground