Description
A Node can be configured in two primary ways. First, you can customize the default node by passing props to control color, border, size, position, etc. Second, you can wrap your own custom components with our Node component and use the exposed actions, properties and events however you choose. Pass the entire component as a child of the Svelvet component to render it on the canvas.+page.svelte
Props
The position of the Node. These correspond to pixel values at the default graph scale. This prop
newly features two way data binding. Please report any issues on GitHub.
Initial dimensions of the node. Pixel value based on initial scale.
Used to specify Node connections ahead of time. Array of tuples representing a node/anchor pair or
of nodeIds themselves. IDs can be strings or numbers. When specifying nodeIds only, connections
are spread evenly across the input anchors of the target.
Identification for the node. If not passed, defaults to an incrementing integer. Used as the HTML
id value for the element taking the form N-id.
A custom Edge component to be used as the default Edge style for the Node. Can be overriden at the
Anchor level.
When passed a value, the initial drop position of the Node is set to the current relative cursor
position or the current viewport center.
When creating custom Nodes, pass the useDefaults prop to use Svelvet’s default Node styling.
The initial background color of the node. Default changes based on theme.
The initial border color of the node. Default changes based on theme.
The initial text color of the node. Default changes based on theme.
Controls the default direction of the canvas. When true, input anchors on top and output anchors
on the bottom. If neither TD or LR are passed, node direction defaults to canvas direction.
Controls the default direction of the canvas. When true, input anchors are placed on left and
output anchors on the right. If neither TD or LR are passed, node direction defaults to canvas
direction.
Initial stacking placement of the node. To force a node to the top or bottom at all times, pass
Infinity or -Infinity.
Determines whether the node properties can be edited via right click. Populates Editor which gives
user the ability to delete selected node, edit label name and edit height and width via resize
button. Resize input does not need unit, just the number - for example: 200.
Enables dynamic Anchor positioning based on relative position of connected Nodes
Actions
Accessed via the let directive. Placed on an element (use:grabHandle) you would like to control
movement and selection of the Node.
Events
Fires when when a mouse up event occurs on the Node. Does not fire if the Node has been dragged
and then released.
Fires whenever a Node is selected and the user triggers a modifier key command with the ‘D’ key
pressed.
Properties
Boolean representing whether or not the node is currently selected. Toggle classes by passing to
an element using the class directive (class:selected).
Functions
Use to programatically create connections from Nodes. Accepts a single Node ID or a [Node ID,
Anchor ID] tuple.

