linkLabels()
function linkLabels(labels, labelStyle?): Label & object[];
Converts a keyed map of LinkLabel definitions into the array of JointJS
labels a link expects, running each through linkLabel. The map key
becomes the label's stable id, so you can address a label later without
relying on array order.
Parameters
| Parameter | Type | Description |
|---|---|---|
labels | Record<string, LinkLabel> | The map of label id to its simplified definition. |
labelStyle? | Partial<LinkLabel> | Shared styling merged into every label before its own values. |
Returns
Label & object[]
The labels array — each entry is a JointJS label whose id is its map key.
Example
import { LinkModel, linkLabels } from '@joint/react';
const link = new LinkModel({
source: { id: 'a' },
target: { id: 'b' },
labels: linkLabels(
{ name: { text: 'orders' }, card: { text: '1..*', position: 0.9 } },
{ fontSize: 12 } // applied to every label
),
});