hydroxy

Node editor

A flow builder on a pan and zoom canvas. Nodes have typed ports; drag from one to another to wire them, and only matching types connect. Select, box-select, drag, snap, undo and minimap, all with a keyboard route.

5 nodes, 4 wires

Tab moves between nodes and their ports. Arrow keys move the selected nodes, or pan when nothing is selected; Shift moves further. On a port, press Enter to start a connection, then Enter on a port of the other side to finish it; Delete removes a port's wires. Delete removes the selection. Control or Command with Z undoes, with Shift and Z redoes, with A selects every node. Plus and minus zoom, 0 resets the zoom and 1 fits everything. Escape cancels.

100%
Stripe webhook
POST /hooks/stripe
Pick fields
Over £500?
amount > 500
Post to #sales
Send receipt

Usage

use hydroxy_leptos::button::{Button, ButtonSize, ButtonVariant};
use hydroxy_leptos::node_editor::{Edge, Graph, Node, NodeEditor, Port, PortKind};
use leptos::prelude::*;

fn payments_flow() -> Graph {
    Graph::new(
        vec![
            Node::new("hook", "Stripe webhook", 0.0, 64.0)
                .kind("trigger")
                .outputs(vec![Port::new("event", "Event", "json")])
                .body(28.0),
            Node::new("pick", "Pick fields", 288.0, 48.0)
                .kind("transform")
                .inputs(vec![Port::new("in", "Payload", "json")])
                .outputs(vec![Port::new("email", "Email", "text"), Port::new("amount", "Amount", "number")]),
            Node::new("check", "Over £500?", 576.0, 0.0)
                .kind("condition")
                .inputs(vec![Port::new("value", "Amount", "number")])
                .outputs(vec![Port::new("yes", "Yes", "boolean")])
                .body(28.0),
            Node::new("slack", "Post to #sales", 864.0, 0.0)
                .kind("action")
                .inputs(vec![Port::new("when", "When", "boolean"), Port::new("text", "Message", "text")]),
            Node::new("mail", "Send receipt", 864.0, 176.0)
                .kind("action")
                .inputs(vec![Port::new("to", "To", "text"), Port::new("body", "Body", PortKind::Any)]),
        ],
        vec![
            Edge::new("hook", "event", "pick", "in"),
            Edge::new("pick", "amount", "check", "value"),
            Edge::new("check", "yes", "slack", "when"),
            Edge::new("pick", "email", "mail", "to"),
        ],
    )
}

/// 300 nodes in a chain, to feel how it holds up.
fn big_flow() -> Graph {
    let nodes = (0..300)
        .map(|i| {
            let (col, row) = (f64::from(i % 20), f64::from(i / 20));
            Node::new(format!("n{i}"), format!("Step {}", i + 1), col * 256.0, row * 128.0)
                .kind("transform")
                .inputs(vec![Port::new("in", "In", "json")])
                .outputs(vec![Port::new("out", "Out", "json")])
        })
        .collect();
    let edges = (1..300).map(|i| Edge::new(&format!("n{}", i - 1), "out", &format!("n{i}"), "in")).collect();
    Graph::new(nodes, edges)
}

#[allow(clippy::needless_pass_by_value, reason = "RenderFn hands each node over by value")]
fn body(node: Node) -> impl IntoView {
    let text = match node.kind.as_str() {
        "trigger" => "POST /hooks/stripe",
        "condition" => "amount > 500",
        _ => "",
    };
    view! { <code style="font: 500 12px/28px var(--font-mono); color: var(--text-3);">{text}</code> }
}

pub fn demo() -> AnyView {
    let graph = RwSignal::new(payments_flow());
    let added = StoredValue::new(0_u32);
    let status = move || graph.with(|g| format!("{} nodes, {} wires", g.nodes.len(), g.edges.len()));
    let add_delay = move |_: leptos::ev::MouseEvent| {
        added.update_value(|n| *n += 1);
        let n = added.get_value();
        graph.update(|g| {
            let node = Node::new(format!("delay{n}"), "Wait 10 minutes", 576.0, 208.0 + f64::from(n) * 24.0)
                .kind("delay")
                .inputs(vec![Port::new("in", "In", PortKind::Any)])
                .outputs(vec![Port::new("out", "Out", PortKind::Any)]);
            g.nodes.push(node);
        });
    };

    view! {
        <div style="display: grid; gap: var(--space-3);">
            <div style="display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center;">
                <Button variant=ButtonVariant::Secondary size=ButtonSize::Sm on_click=add_delay>"Add a delay"</Button>
                <Button variant=ButtonVariant::Ghost size=ButtonSize::Sm on_click=move |_| graph.set(big_flow())>"Load 300 nodes"</Button>
                <Button variant=ButtonVariant::Ghost size=ButtonSize::Sm on_click=move |_| graph.set(payments_flow())>"Reset"</Button>
                <span style="font: var(--text-label); color: var(--text-3);">{status}</span>
            </div>
            <NodeEditor graph=graph on_change=move |g: Graph| graph.set(g) render=body label="Payment automation" />
        </div>
    }
    .into_any()
}

Anatomy

Componentdata-partRenders
NodeEditorrootWrapper for the toolbar, canvas and screen reader text
toolbarrole=toolbar: zoom out, zoom level, zoom in, fit, undo, redo, delete
viewportrole=application canvas that takes every pointer and key event. Grid dots via --ox-grid*. data-panning, data-connecting
worldThe layer that pans and zooms, by one CSS transform
edges<svg> of wires. Each edge is a <path>, coloured by its output's type (--ox-wire); data-selected
previewThe dashed wire following the pointer while connecting
nodeTabbable role=group with aria-roledescription=node. data-selected, data-dragging, data-kind
header / titleTitle bar; drag it to move the node
port<button> per port, data-side input or output, --ox-port colour. data-wired, data-accept while connecting, aria-pressed on the port a keyboard connection starts from
contentThe host's render output, in the node's body height. Keeps its own pointer and key events
marqueeShift-drag selection box
minimapOverview of every node and the view; click or drag to move the view
instructions / liveVisually hidden keyboard help and a role=status region for connections, deletes and undo

Keyboard

KeyDoes
TabMoves between nodes and their ports. Focusing a node selects it
Enter / Space on a portStarts a connection; on a port of the other side, finishes it. Again on the same port cancels
Delete on a portRemoves that port's wires
Arrow keysMove the selected nodes one grid step, or pan when nothing is selected. Shift moves four steps
Delete / BackspaceDeletes the selected nodes and wires
Ctrl/Cmd + Z, Shift + Z, YUndo and redo
Ctrl/Cmd + ASelects every node
+ / − / 0 / 1Zoom in, zoom out, back to 100%, fit everything
EscapeCancels a connection, else clears the selection
Space + drag, middle dragPans from anywhere, even over a node
Shift + click, Shift + dragAdds to the selection, draws a selection box

Props

PropTypeNotes
graphSignal<Graph>Required. Graph::new(nodes, edges). Node::new(id, title, x, y).inputs(..).outputs(..).body(h). Port::new(id, label, kind); PortKind::Any matches everything
on_changeCallback<Graph>Called with the graph after each committed change (drop, connect, delete, nudge, undo)
renderRenderFn<Node>Renders a node's content area, body() pixels tall
labelStringAccessible name for the canvas
gridf64Grid spacing. Default 16
snapboolSnap dragged nodes to the grid. Default true
minimapboolShow the minimap. Default true
heightStringCSS height of the canvas. Default 480px
Actions
Button
Icon button
Toolbar
Theme menu
Display
Avatar
Badge
Card
Chip
Code block
Markdown
Doc card
Due pill
Kbd
Priority mark
Source chip
Space icon
Status diamond
Tag
Value diff
Carousel
Reveal
Media timeline
QR code
Transcript viewer
Audio waveform
Audio player
Forms
Calendar
Checkbox
Combobox
Date picker
Color picker
Cron builder
Theme editor
Mention input
Signature pad
Image cropper
Date field
Date range picker
Duration field
Quantity stepper
Filter chip
Input
Markdown editor
Radio group
Search field
Segmented control
Select
Slider
Range slider
Rating
Toggle button
File dropzone
Upload queue
Attachment
Switch
Tags input
Number field
Money field
Phone field
Time field
OTP input
Password field
Questionnaire
Availability picker
Voice input
Recording control
Inline edit
Async validated input
Shortcut recorder
Data
Spreadsheet grid
Week scheduler
Virtual list
Stat card
Step track
Kanban board
Sortable list
Filter builder
Data table
Grid
Access editor
File manager
Gantt chart
Log stream
Diff viewer
JSON inspector
Terminal
Node editor
Whiteboard
Navigation
Table of contents
Breadcrumb
Tabs
Wizard
Nav item
Nav section
Tree view
Pagination
Menubar
Navigation menu
Saved views
Layout
Master detail
App shell
Sidebar layout
Resizable panels
Dashboard layout
Dock layout
Feedback
Callout
Check list
Empty state
Progress bar
Toast
Approval card
Skeleton
Notification center
Bars
Bar chart
Diverging bar chart
Span chart
Pictogram chart
Stacked bar chart
Funnel chart
Bullet chart
Waffle chart
Marimekko chart
Dot plot chart
Error bar chart
Pareto chart
Waterfall chart
Lollipop chart
Grouped bar chart
Bar race chart
KPIs and frames
Chart frame
Metric card
Sparkline
Points
Scatter chart
Smith chart
Strip plot
Beeswarm chart
Parallel coordinates
Ternary chart
Bland-Altman chart
Quiver chart
Connected scatter chart
Grids and tables
Heatmap chart
Chart table
Cohort chart
Radial
Radial charts
Radar chart
Polar area chart
Stat ring
Clock chart
Spiral chart
Lines and areas
Bump chart
Slope chart
Line chart
Composed chart
Small multiples
Cycle plot chart
Horizon chart
Stacked area chart
Threshold chart
Split line chart
Linked charts
Confidence band chart
Forecast fan chart
Step chart
Range area chart
Distributions
Contour chart
Histogram
Box plot
Density chart
Ridgeline chart
Violin chart
Q-Q chart
Survival chart
ECDF chart
Raincloud plot
Forest plot
Maps
Geo map
Bubble map
Hexbin map
Cartogram
Flow map
Parts of a whole
Donut chart
Voronoi treemap
Nested donut chart
Treemap chart
Sunburst chart
Bubble pack chart
Icicle chart
Flame graph chart
Pie chart
Word cloud
Relationships
Sankey chart
Network chart
Chord chart
UpSet chart
Venn chart
Alluvial chart
Adjacency matrix chart
Dependency graph chart
Tree chart
Arc diagram
Hive plot
Edge bundling
Finance
Candlestick chart
OHLC chart
Depth chart
Renko chart
Time
Timeline chart
Calendar heatmap chart
Spectrogram chart
Marey chart
Overlays
Tour
Lightbox
Alert dialog
Command palette
Dialog
Menu
Popover
Tooltip
Sheet
Hover card
Context menu
Utilities
Pacer
Hotkeys
Disclosure
Accordion
Collapsible
Chat
Chat bubble
Voice session
Composer
Thread
Thread list
Assistant composer
Assistant MCP
Assistant modal
Assistant thread
Assistant thread list
Message scroller
Insight note
Emoji picker
Tool trace
Model picker
Citation popover
Activity
Activity feed
Comment thread
Timeline
Presence bar
Live cursors
Reaction bar
Guides
Getting started
All components
All charts