Expand description
§dioxus-flow
A react-flow-style node graph component library for Dioxus: pannable/zoomable canvas, draggable nodes, connectable handles, selectable animated edges, automatic layered layout, minimap, controls and background — with fully customizable node and edge rendering.
ⓘ
use dioxus::prelude::*;
use dioxus_flow::prelude::*;
#[component]
fn App() -> Element {
let nodes = use_signal(|| vec![
Node::new("1", "Source", (0.0, 0.0)).node_type("input"),
Node::new("2", "Sink", (0.0, 140.0)).node_type("output"),
]);
let edges = use_signal(|| vec![Edge::new("1", "2").animated(true)]);
rsx! {
div { style: "width: 100vw; height: 100vh;",
Flow { nodes, edges, fit_view: true,
Background {}
Controls {}
MiniMap {}
}
}
}
}Re-exports§
pub use background::Background;pub use background::Background;pub use controls::Controls;pub use controls::Controls;pub use edge::SeatEdgeLabels;pub use edge::SeatEdgeLabels;pub use edge::SeatEdges;pub use edge::SeatEdges;pub use flow::Flow;pub use flow::Flow;pub use flow::WorldLayer;pub use flow::WorldLayer;pub use minimap::MiniMap;pub use minimap::MiniMap;pub use node::DefaultNodeView;pub use node::DefaultNodeView;pub use node::Handle;pub use node::Handle;
Modules§
- paper
- The graph paper behind the map: dots on the snap grid, with a heavier mark every fifth one.
- place
- Where something new goes when nothing said exactly where.
- ports
- Seat-based ports: discrete connection points packed around a node’s rounded rim, and the curves between them.
- prelude
- Everything you typically need.
- press
- When a press has become a drag.
- settle
- Turns transient rectangle geometry into a valid resting layout.
Structs§
- Connect
End - How a connection gesture ended, whatever it ended on. Passed to
on_connect_end;connectionisNonewhen the drag was released over nothing — the hook for “drop on empty canvas to create a node there”. - Connection
- A pending or completed connection between two handles.
- Delete
Request - What a Delete/Backspace press would remove: the selected nodes, plus
edges that are selected or touch a selected node. Passed to
Flow’son_deleteso apps can confirm, snapshot for undo, or veto. - Edge
- An edge connecting two nodes.
- Edge
Geometry - Inputs for building an edge path between two handle anchors.
- Edge
Path - A rendered edge path: the SVG
dattribute and a label anchor point. - Edge
View Ctx - Everything a custom edge view needs: the edge, its resolved anchors, and the default path (so custom edges can restyle without redoing the math).
- Flow
Core - The non-generic heart of a flow, shared through context with every child
(layers, handles,
Background,Controls,MiniMap, and user components). All fields areCopyhandles to reactive state. - Flow
Handle - A handle for controlling a
crate::Flowfrom the component that owns it. - Grid
- The lattice positions come to rest on. Snapping is the plane’s business — the background draws this grid, and a release lands on it — while what may occupy a cell is the application’s.
- Handle
Geom - Geometry of a registered handle, relative to its node.
- Handle
Key - Uniquely identifies a handle within a flow.
- Layout
Node - Node input to
compute_layout. - Layout
Options - Options for
compute_layout. - Node
- A node in the flow graph.
- Node
Geom - Lightweight per-node geometry snapshot used by edges, minimap and fit-view. Derived reactively from the node list.
- Node
View Ctx - Context available to custom node views.
- Point
- A point (or vector) in 2D space. Flow coordinates unless stated otherwise.
- Rect
- An axis-aligned rectangle.
- Seat
Edge View Ctx - Everything a seat-anchored custom edge (or label) view needs: the edge,
its solved anchors (point and outward normal at each end), and the full
rim-aware geometry — trimmed path, untrimmed outline for halos and grab
bands, arrowhead polygons, the label point, and
point_at/nearest_label_positionfor label interactions. Computed once per edge with the edge’s ownweight,label_positionand markers, so a custom view never redoes the math. - Size
- A width/height pair.
- Viewport
- The pan/zoom state of the flow canvas.
Enums§
- Anchor
Mode - How a
crate::Flow’s edges find their endpoints on nodes. - Background
Variant - Edge
Kind - How an edge’s path is drawn.
- Handle
Kind - Whether a handle is a source (edges start here) or a target (edges end here).
- Interaction
- Coarse interaction state. Per-frame details (drag offsets, last pointer
position) live in the non-reactive [
DragState] so pointer-move frames don’t invalidate subscribers of this signal. - Layout
Direction - Direction of rank progression.
- Marker
Kind - Arrowhead marker at the end of an edge.
- Side
- A side of a node, used for handle placement, seat naming and edge routing.
Statics§
- STYLESHEET
- The component styles
Canvasinjects at runtime, public so that tests and server-side renderers can install the same sheet themselves.
Functions§
- Background
- A pan/zoom-aware background pattern. Render as a child of
crate::Flow. - Canvas
- The pannable/zoomable surface every flow is drawn on.
- Controls
- Zoom-in, zoom-out and fit-view buttons. Render as a child of
crate::Flow; add extra buttons as children. - Default
Node View - The built-in node view: a simple labeled box. Nodes typed
"input"omit the target handle,"output"omits the source handle. - Flow
- An interactive node-graph canvas, in the spirit of react-flow.
- Handle
- A connection point on a node. Place handles anywhere inside a custom node view; edges anchor to them and new connections can be dragged out of them.
- MiniMap
- A minimap showing all nodes and the visible viewport. Click to jump.
Render as a child of
crate::Flow. - Seat
Edge Labels - The labels of seat-anchored edges, as one world-space layer over every curve — so a connection crossing another never draws through its words.
- Seat
Edges - The curves of seat-anchored edges, as one world-space layer.
- World
Layer - A layer inside the canvas that shares the viewport transform: children are
laid out in flow coordinates. Render as a child of
CanvasorFlowfor world-space overlays (annotations, guides, custom edge layers…). - bezier_
path - Cubic bezier between the anchors, curving out of each side.
- compute_
layout - Compute positions (top-left corners) for
nodesgiven directededges(pairs of node ids). Unknown ids in edges are ignored; cycles are fine. - edge_
path - Build the path for the given edge kind.
- side_
point - The point on the boundary of
rectat fractionfrac(0..=1) alongside. - smooth_
step_ path - Orthogonal path with rounded corners.
- straight_
path - A straight line between the anchors.
- use_
flow - Access the surrounding flow’s state from any component rendered inside a
crate::Flow(custom nodes, edges, controls, overlays…). - use_
flow_ handle - Create a
FlowHandleto pass to acrate::Flow’shandleprop. - use_
overlay_ inset - Reserve a screen-space band of
thicknesspixels alongsideof the container, from inside an overlay component (the built-incrate::Controlsandcrate::MiniMapdo this). Fit-view centers the graph in the remaining area so nodes don’t land underneath overlay panels.
Type Aliases§
- Id
- Identifier for nodes, edges and handles.