Edge Label Renderer
If you need more control of your edge labels, you can use the EdgeLabelRenderer
component. It’s a portal component that lets you render edge labels as divs on top of the edges. If you want to add mouse interactions you need to set pointer-events: all
on the label.
<script lang="ts">
import { writable } from 'svelte/store';
import { SvelteFlow, Background, type Node, type Edge, type EdgeTypes } from '@xyflow/svelte';
import '@xyflow/svelte/dist/style.css';
import { initialNodes, initialEdges } from './nodes-and-edges';
import CustomEdge from './CustomEdge.svelte';
import CustomEdgeStartEnd from './CustomEdgeStartEnd.svelte';
const nodes = writable<Node[]>(initialNodes);
const edges = writable<Edge[]>(initialEdges);
const edgeTypes: EdgeTypes = {
custom: CustomEdge,
'start-end': CustomEdgeStartEnd
};
</script>
<div style="height:100vh;">
<SvelteFlow {nodes} {edges} {edgeTypes} fitView>
<Background />
</SvelteFlow>
</div>