Connection Line
A Connection Line is the edge that appears when you click on a handle and drag. It represents a possible edge and can snap to other valid handles in close proximity.
You can implement your own Connection Line by passing a snippet to the connectionLine
prop. We do not pass any additional props to the snippet as the useConnection
hook gives you access to the current connection
.
<script lang="ts">
import {
SvelteFlow,
Background,
type Edge,
type Node,
MiniMap,
} from '@xyflow/svelte';
import CustomNode from './CustomNode.svelte';
import ConnectionLine from './ConnectionLine.svelte';
import '@xyflow/svelte/dist/style.css';
const nodeTypes = {
custom: CustomNode,
};
let nodes = $state.raw<Node[]>([
{
id: 'connectionline-1',
type: 'custom',
data: { label: 'Node 1' },
position: { x: 250, y: 5 },
},
]);
let edges = $state.raw<Edge[]>([]);
</script>
<SvelteFlow
bind:nodes
bind:edges
{nodeTypes}
fitView
connectionLineComponent={ConnectionLine}
>
<Background />
<MiniMap />
</SvelteFlow>