Skip to Content
You are viewing the v1 docs of Svelte Flow. You can find the latest version here.
ExamplesEdges

Edge Labels

This example demonstrates how to add and customize labels on edges in Svelte Flow. Edge labels can be used to display additional information about connections, such as weights, types, or descriptions. You can style and position labels to match your visualization needs.

import type { Node, Edge } from '@xyflow/svelte'; export const initialNodes: Node[] = [ { id: '1', type: 'input', data: { label: 'Node 1' }, position: { x: 0, y: 0 }, }, { id: '2', data: { label: 'Node 2' }, position: { x: 0, y: 300 } }, { id: '3', data: { label: 'Node 3' }, position: { x: 200, y: 0 } }, { id: '4', data: { label: 'Node 4' }, position: { x: 200, y: 300 } }, ]; export const initialEdges: Edge[] = [ { id: 'e1-2', source: '1', target: '2', data: { label: 'edge label', }, type: 'custom', }, { id: 'e3-4', source: '3', target: '4', data: { startLabel: 'start edge label', endLabel: 'end edge label', }, type: 'start-end', }, ];
Last updated on