1
1
<script setup >
2
2
import LogosJavascript from ' ~icons/logos/javascript' ;
3
- import LogosTypescript from ' ~icons/logos/typescript-icon' ;
4
3
import { ref , h } from ' vue' ;
5
4
import { Handle , Position , VueFlow } from ' @vue-flow/core' ;
5
+ import { Background } from ' @vue-flow/background' ;
6
6
7
7
const CustomNode = (props ) => h (' div' , [
8
8
h (Handle, { connectable: false , type: ' target' , position: Position .Top }),
@@ -60,10 +60,11 @@ Here's how you can use CSS classes to add a pop of color or alter the font style
60
60
```
61
61
62
62
<div class =" mt-4 bg-[var(--vp-code-block-bg)] rounded-lg h-50 " >
63
- <VueFlow v-model =" elements " :pan-activation-key-code = " null " :pan-on-scroll = " false " :zoom-on-scroll = " false " :pan-on-drag = " false " fit-view-on-init >
63
+ <VueFlow v-model =" elements " fit-view-on-init >
64
64
<template #node-custom="props">
65
65
<CustomNode v-bind="props" />
66
66
</template>
67
+ <Background />
67
68
</VueFlow >
68
69
</div >
69
70
@@ -86,14 +87,12 @@ Below are a couple of examples on how you can do this:
86
87
87
88
Directly styling the Vue Flow component:
88
89
89
- ``` html{4-5}
90
- <div style="height: 300px">
91
- <VueFlow
92
- v-model="elements"
93
- class="my-diagram-class"
94
- :style="{ background: 'red' }"
95
- />
96
- </div>
90
+ ``` vue{3-4}
91
+ <VueFlow
92
+ v-model="elements"
93
+ class="my-diagram-class"
94
+ :style="{ background: 'red' }"
95
+ />
97
96
```
98
97
99
98
Styling nodes/edges with a style or class attribute:
@@ -117,25 +116,6 @@ const nodes = ref([
117
116
])
118
117
```
119
118
120
- ``` ts{10-14} [<LogosTypescript />]
121
- import type { Node } from '@vue-flow/core';
122
-
123
- /* Customizing node by assigning class and style properties */
124
- const nodes = ref<Node[]>([
125
- {
126
- id: '1',
127
- label: 'Node 1',
128
- position: { x: 250, y: 5 },
129
-
130
- // Add a class name to the node
131
- class: 'my-custom-node-class',
132
-
133
- // You can pass an object containing CSSProperties or CSS variables
134
- style: { backgroundColor: 'green', width: '200px', height: '100px' },
135
- },
136
- ])
137
- ```
138
-
139
119
:::
140
120
141
121
### [ Redefining Styles with CSS variables] ( /typedocs/types/CSSVars )
@@ -167,20 +147,6 @@ const elements = ref([
167
147
])
168
148
```
169
149
170
- ``` ts{8-9} [<LogosTypescript />]
171
- import type { Elements } from '@vue-flow/core';
172
-
173
- const elements = ref<Elements>([
174
- {
175
- id: '1',
176
- label: 'Node 1',
177
- position: { x: 100, y: 100 },
178
- /* Overriding the `--vf-node-color` variable to change node border, box-shadow and handle color */
179
- style: { '--vf-node-color': 'blue' }
180
- },
181
- ])
182
- ```
183
-
184
150
:::
185
151
186
152
## CSS Variables
0 commit comments