Svelvet
Primary canvas component configurable via props. Enables zoom, pan and translation of the canvas.
Description
Svelvet is the wrapping parent component that renders out nodes and edges. It is configurable via props, but no props are required. Many props can be set globally at this level and then overriden at the Node, Edge or Anchor level.
Props
Width of the canvas window on the DOM. If not passed, element will fill its wrapping container.
Height of the canvas window on the DOM. If not passed, element will fill its wrapping container.
Identification for the canvas. If not passed, defaults to an incrementing integer. Used as the HTML id value for the element taking the form G-id.
Boolean used to render the default Minimap component. Just pass “minimap” rather than minimap= .
Initial translation of the graph. Does not currently feature two-way data binding.
Boolean used to render the default Controls component. Just pass “controls” rather than controls= .
A custom Edge component to be used as the global Edge style for the canvas. Can be overridden at the Node and Anchor level.
Enum representing the global edge style for the canvas. Overriden when passing custom Edges.
Enum representing the global end styles for the canvas. First element in array will be applied to the start of the edge, second element in array will be applied to the end of the edge. Overriden when passing custom Edges.
Pixel value at default scale that Nodes should snap to when being moved.
Prevents zooming on the canvas.
Prevents panning on the canvas.
Allows the Node properties to be edited via CTRL+click.
Adjusts scale and translation to fit all Nodes in view on mount.
Locks node movement, but still allows the canvas to be panned.
Sets the initial zoom level for the canvas. Below 1 zooms out, above 1 zooms in.
A string associated with a custom theme created using a :root[svelvet-theme="theme-name"]
CSS
selector. Svelvet reserves light
and dark
.
canvas representation using Mermaid-inspired string syntax. Great for quickly developing simple Nodes and Edges.
An object of key value pairs where the key is a Node ID and the value a Node configuration object. Used only when creating canvases via the Mermaid syntax.
Boolean controlling the directionality of the canvas. TD being set false by default means that the canvas direction is inherently left-to-right. Pass “TD” as a prop to change the direction to top-down.
Boolean controlling whether or not Shift + Click enables the selection of multiple components. This feature is enabled by default.
Sets whether Edges should, by default, be placed above or below connected Nodes. Can be set to
all
to force Edges above all nodes. Otherwise, true essentially turns on raiseEdgesOnSelect
,
but places the edges at higher z-Index than the Node.
When a Node is selected, this prop controls whether the z-index of a connected edge should be
raised. Setting to true
raises the edge regardless of if the source or target is selected.
Sets global key modifier used to detect select all and duplicate events.
When using a trackpadPan, setting this prop to true enables two finger pan on the Graph and pinch to zoom. Will conflict with scroll behavior on mice. This mode of navigation can be enabled dynamically by hodling down the meta key.
Events
Fires when an Edge connection is started and not completed. Does not fire on drops after a disconnection.