
React Flow
Implement typed custom React Flow edges with paths, labels, and animations for node-based builder UIs.
Install
npx skills add https://github.com/existential-birds/beagle --skill react-flowWhat is this skill?
- Defines typed custom edges with EdgeProps and a dedicated edge type (e.g. timeLabel).
- Covers path utilities, BaseEdge, animated edges, and SVG or EdgeText labels.
- Shows interactive labels via EdgeLabelRenderer and a full time-label edge example.
- Includes edge type registration and default edge options for app-wide consistency.
- Targets @xyflow/react TypeScript APIs for source/target geometry and positions.
Adoption & trust: 860 installs on skills.sh; 61 GitHub stars; 3/3 security scanners passed (skills.sh audits); trending (+100% hot-view momentum).
Recommended Skills
Journey fit
Custom edges are UI implementation work that belongs on the Build shelf under frontend, where solo builders wire diagram libraries into products. The skill documents EdgeProps, BaseEdge, EdgeLabelRenderer, and registration patterns—core React Flow frontend patterns, not backend or ship QA.
Common Questions / FAQ
Is React Flow safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.
SKILL.md
READMESKILL.md - React Flow
# Custom Edges Custom edges in React Flow use the `EdgeProps<T>` typing pattern and path utility functions to render connections between nodes. ## Table of Contents - [Edge Type Definition](#edge-type-definition) - [EdgeProps Structure](#edgeprops-structure) - [Path Utility Functions](#path-utility-functions) - [BaseEdge Component](#baseedge-component) - [EdgeLabelRenderer for Interactive Labels](#edgelabelrenderer-for-interactive-labels) - [Animated Edges](#animated-edges) - [SVG Text Labels](#svg-text-labels) - [EdgeText Component](#edgetext-component) - [Time Label Edge Example](#time-label-edge-example) - [Edge Registration](#edge-registration) - [Default Edge Options](#default-edge-options) ## Edge Type Definition Define custom edge types with typed data: ```typescript import { Edge, EdgeProps } from '@xyflow/react'; // Define the custom edge type export type TimeLabelEdge = Edge<{ time: string; label: string }, 'timeLabel'>; // Component receives EdgeProps export default function TimeLabelEdge(props: EdgeProps<TimeLabelEdge>) { // Edge implementation } ``` ## EdgeProps Structure The `EdgeProps` type includes these key properties: ```typescript type EdgeProps<T extends Edge = Edge> = { id: string; type?: string; source: string; target: string; sourceX: number; sourceY: number; targetX: number; targetY: number; sourcePosition: Position; targetPosition: Position; data?: T['data']; selected?: boolean; animated?: boolean; style?: CSSProperties; markerStart?: string; markerEnd?: string; sourceHandleId?: string | null; targetHandleId?: string | null; label?: ReactNode; labelStyle?: CSSProperties; labelShowBg?: boolean; labelBgStyle?: CSSProperties; labelBgPadding?: [number, number]; labelBgBorderRadius?: number; interactionWidth?: number; pathOptions?: any; }; ``` ## Path Utility Functions React Flow provides several path generators: ### getBezierPath Creates smooth curved paths: ```typescript import { FC } from 'react'; import { BaseEdge, EdgeProps, getBezierPath } from '@xyflow/react'; const CustomEdge: FC<EdgeProps> = ({ id, sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition, data, }) => { const [edgePath, labelX, labelY] = getBezierPath({ sourceX, sourceY, sourcePosition, targetX, targetY, targetPosition, curvature: 0.25, // Optional: control curve amount (default 0.25) }); return <BaseEdge path={edgePath} id={id} />; }; ``` ### getStraightPath Creates direct straight lines: ```typescript import { getStraightPath } from '@xyflow/react'; const [edgePath, labelX, labelY] = getStraightPath({ sourceX, sourceY, targetX, targetY, }); ``` ### getSmoothStepPath Creates orthogonal paths with smooth corners: ```typescript import { getSmoothStepPath } from '@xyflow/react'; const [edgePath, labelX, labelY] = getSmoothStepPath({ sourceX, sourceY, sourcePosition, targetX, targetY, targetPosition, borderRadius: 8, // Optional: corner radius offset: 20, // Optional: offset from node }); ``` ### getSmoothStepPath with borderRadius: 0 (Step Edge) For orthogonal paths with sharp corners, use `getSmoothStepPath` with `borderRadius: 0`: ```typescript import { getSmoothStepPath } from '@xyflow/react'; const [edgePath, labelX, labelY] = getSmoothStepPath({ sourceX, sourceY, sourcePosition, targetX, targetY, targetPosition, borderRadius: 0, // Sharp corners (step edge) offset: 20, // Optional: offset from node }); ``` ## BaseEdge Component The `BaseEdge` component renders the path with proper styling: ```typescript import { BaseEdge, EdgeProps, getBezierPath } from '@xyflow/react'; function CustomEdge(props: EdgeProps) { const [edgePath] = getBezierPath(props); return ( <BaseEdge id={props.id} path={edgePath} style={props.style} markerEnd={props.markerEnd} markerStart={props.markerStart} interactionWidth={20} //