Skip to content

Custom component as node-content #691

Answered by bcakmakoglu
TerryDieckmann asked this question in Q&A
Discussion options

You must be logged in to vote

You can use components as labels.

import CustomNodeLabel from './NodeLabel.vue'

const elements = ref<Elements>([
  { id: '1', type: 'input', label: CustomNodeLabel, position: { x: 250, y: 5 } },
  { id: '2', type: 'output', label: 'Node 2', position: { x: 100, y: 100 } },
  { id: '3', label: 'Node 3', position: { x: 400, y: 100 } },
])

If you need to pass props to this label, you can use it like this:

const elements = ref<Elements>([
  { id: '1', type: 'input', label: h(CustomNodeLabel, { label: 'Input 1' }), position: { x: 250, y: 5 } },
  { id: '2', type: 'output', label: 'Node 2', position: { x: 100, y: 100 } },
  { id: '3', label: 'Node 3', position: { x: 400, y: 100 } },
])

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@TerryDieckmann
Comment options

Answer selected by TerryDieckmann
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants