Status Edge

PreviousNext

A React Flow edge component that provides visual feedback through color-coded states.

Docs
simple-aiui

Preview

Loading preview…
./src/registry/ui/flow/status-edge.tsx
import {
	type Edge,
	type EdgeProps,
	BaseEdge as FlowBaseEdge,
	getBezierPath,
} from "@xyflow/react";
import type { CSSProperties } from "react";

export type StatusEdge = Edge<
	{
		error?: boolean;
	},
	"status"
> & {
	type: "status";
	sourceHandle: string;
	targetHandle: string;
};

export function StatusEdge({
	sourceX,
	sourceY,
	targetX,
	targetY,
	sourcePosition,
	targetPosition,
	data,
	selected,
}: EdgeProps<StatusEdge>) {
	const [edgePath] = getBezierPath({
		sourceX,
		sourceY,
		sourcePosition,
		targetX,
		targetY,
		targetPosition,
	});

	const edgeStyle: CSSProperties = {
		stroke: data?.error ? "#ef4444" : selected ? "#3b82f6" : "#b1b1b7",
		strokeWidth: selected ? 3 : 2,
		transition: "stroke 0.2s, stroke-width 0.2s",
	};

	return <FlowBaseEdge path={edgePath} style={edgeStyle} />;
}

Installation

npx shadcn@latest add @simple-ai/status-edge

Usage

import { StatusEdge } from "@/components/ui/status-edge"
<StatusEdge />