Selected node style #32
-
Hi, |
Beta Was this translation helpful? Give feedback.
Answered by
bcakmakoglu
Feb 26, 2022
Replies: 1 comment
-
You can pass classes (or styles) to nodes as a property/option. const elements = ref<Elements>([
{ id: '1', type: 'input', label: 'Node 1', position: { x: 250, y: 5 }, class: 'some-class', style: { color: 'red' } },
]) You can change the styles whenever you want (if you want to keep reactivity on your initial elements, don't map over them but use a forEach loop to change properties) <script setup lang="ts">
const elements = ref([...])
const toggleClasses = () => {
elements.value.forEach(el => {
if (el.selected) el.class = 'some-selected-class'
}
}
</script>
<template>
<VueFlow v-model="elements">
<button @click="toggleClasses">Toggle classes</button>
</VueFlow>
</template> |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
bcakmakoglu
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can pass classes (or styles) to nodes as a property/option.
You can change the styles whenever you want (if you want to keep reactivity on your initial elements, don't map over them but use a forEach loop to change properties)