How to create custom shapes using template binding in Vue Diagram
The Syncfusion® Vue Diagram supports rendering custom HTML content within nodes using template binding. This allows you to create nodes with dynamic HTML elements such as buttons, forms, or other content.
To define a node with custom HTML content, set the shape
property of the node to HTML. Specify the template content using the nodeTemplate
function. Here’s how:
<template>
<div class="control-section">
<div class="content-wrapper">
<ejs-diagram
ref="diagramObj"
id="diagram"
:nodes="nodes"
:getNodeDefaults="getNodeDefaults"
:nodeTemplate="nodeTemplate"
></ejs-diagram>
</div>
</div>
</template>
data: function () {
return {
width: '100%',
height: '700px',
nodes: [{
id: 'node1',
offsetX: 100,
offsetY: 100,
width: 100,
height: 100
}],
nodeTemplate: function () {
return {
template: createApp({}).component('nodeTemplate', NodeTemplate),
};
},
getNodeDefaults: (obj, diagram) => {
obj.shape ={type:'HTML'}
obj.backgroundColor = '#6BA5D7'
return obj;
},
};
},
Define the Custom HTML Template:
The custom HTML content is defined inside the template.vue component.
<template>
<div>
<button @click="nodeBtnClick">Button</button>
</div>
</template>
Sample: Click Here
Conclusion
I hope you enjoyed learning about How to create custom shapes using template binding in Vue Diagram. You can refer to our Vue Diagram feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our Vue Diagram example to understand how to create and manipulate data. For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls. If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!