Skip to main content
Version: 4.3

linkAttributes()

function linkAttributes(link): Attributes;

Expands the declarative React link shorthand (style, labelMap) into the native attributes JointJS understands, so you can describe a link with the friendly preset fields instead of raw attrs and labels.

  • style → SVG attrs via linkStyle.
  • labelMap → a native labels array via linkLabels.
  • labels (array) → passed through unchanged.

Parameters

ParameterTypeDescription
linkLinkAttributesThe link record to convert.

Returns

Attributes

JointJS-compatible cell attributes.

Throws

When link is not an object, or when both labelMap and labels are set on the same link.

Example

Expand the declarative preset input into native attributes and hand them to a cell model:

import { LinkModel, linkAttributes } from '@joint/react';

const link = new LinkModel(
linkAttributes({
source: { id: 'a' },
target: { id: 'b' },
style: { color: '#333', width: 2 }, // preset shorthand
labelMap: { mid: { text: 'edge', position: 0.5 } },
})
);

Stay in the know

Be where thousands of diagramming enthusiasts meet

Star us on GitHub