Skip to content

tisoap/react-flow-smart-edge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

274 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React Flow Smart Edge

Custom edges for React Flow that never intersect with other nodes, using pathfinding.

TypeScript Storybook ESLint

Smart Edge

Documentation

Full documentation: tisoap.github.io/react-flow-smart-edge/docs

Interactive Storybook examples are published on Chromatic. Source: src/stories/SmartEdge.stories.tsx.

Install

npm install @tisoap/react-flow-smart-edge

Requires React Flow v12+ (@xyflow/react).

Quick example

import { ReactFlow } from "@xyflow/react";
import { SmartBezierEdge } from "@tisoap/react-flow-smart-edge";
import "@xyflow/react/dist/style.css";

const nodes = [
  { id: "1", data: { label: "Node 1" }, position: { x: 300, y: 100 } },
  { id: "2", data: { label: "Node 2" }, position: { x: 300, y: 200 } },
];

const edges = [{ id: "e21", source: "2", target: "1", type: "smart" }];

const edgeTypes = { smart: SmartBezierEdge };

export function Graph() {
  return (
    <ReactFlow
      defaultNodes={nodes}
      defaultEdges={edges}
      edgeTypes={edgeTypes}
      fitView
    />
  );
}

Edge components

Export React Flow equivalent
SmartBezierEdge BezierEdge
SmartStraightEdge StraightEdge
SmartStepEdge StepEdge
SmartSmoothStepEdge SmoothStepEdge
SmartFloatingEdge Floating edges example
SmartEditableEdge Editable edge example

Configure options with createSmartEdge("step", { gridRatio: 5 }) or build custom edges with getSmartEdge. See the docs for guides, API reference, and live examples.

Support

ko-fi

GitHub Sponsors

Development

npm ci
npm run storybook    # demos + tests (port 6006)
npm run docs         # Docusaurus dev server → http://localhost:3000/docs
npm run check        # lint, types, spellcheck
npm run test         # Storybook interaction tests
npm run build-docs   # static docs site → website/build

License

MIT

About

Custom Edge for React Flow that never intersects with other nodes

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages