@@ -35,15 +35,51 @@ import '@vue-flow/controls/dist/style.css'
35
35
</template>
36
36
```
37
37
38
+ You can also customize the controls by using the provided slots and slot props.
39
+
40
+ ``` vue
41
+ <script setup>
42
+ import { VueFlow } from '@vue-flow/core'
43
+ import type { ControlType } from '@vue-flow/controls'
44
+ import { ControlButton, Controls } from '@vue-flow/controls'
45
+
46
+ // import default controls styles
47
+ import '@vue-flow/controls/dist/style.css'
48
+
49
+ // import custom tooltip component
50
+ import Tooltip from './Tooltip.vue'
51
+
52
+ const tooltips: Record<ControlType, string> = {
53
+ 'zoom-in': 'Zoom In',
54
+ 'zoom-out': 'Zoom Out',
55
+ 'fit-view': 'Fit View',
56
+ 'interactive': 'Lock/Unlock Interaction',
57
+ }
58
+ </script>
59
+
60
+ <template>
61
+ <VueFlow>
62
+ <Controls>
63
+ <template #control-item="{ control, onClick, icon }">
64
+ <Tooltip :text="tooltips[control]">
65
+ <ControlButton @click="onClick">
66
+ <component :is="icon" />
67
+ </ControlButton>
68
+ </Tooltip>
69
+ </template>
70
+ </Controls>
71
+ </VueFlow>
72
+ </template>
73
+ ```
38
74
39
75
## [ Props] ( /typedocs/interfaces/ControlProps )
40
76
41
- | Name | Definition | Type | Optional | Default |
42
- | -----------------| ----------------------------------------| ------------------------------------------------| ----------| ---------|
43
- | showZoom | Show zoom btn | boolean | true | true |
44
- | showFitView | Show fit-view btn | boolean | true | true |
45
- | showInteractive | Show lock interactive btn | boolean | true | true |
46
- | showZoom | Show zoom button | boolean | true | true |
77
+ | Name | Definition | Type | Optional | Default |
78
+ | -----------------| ----------------------------------------| ------------------------------------------------------- | ----------| ---------|
79
+ | showZoom | Show zoom btn | boolean | true | true |
80
+ | showFitView | Show fit-view btn | boolean | true | true |
81
+ | showInteractive | Show lock interactive btn | boolean | true | true |
82
+ | showZoom | Show zoom button | boolean | true | true |
47
83
| fitViewParams | Params to use on fit-view button click | [ FitViewParams] ( /typedocs/type-aliases/FitViewParams ) | true | - |
48
84
49
85
## Emits
@@ -59,14 +95,15 @@ import '@vue-flow/controls/dist/style.css'
59
95
60
96
### Control Buttons
61
97
62
- | Name | Definition |
63
- | ---------------------| ----------------------------|
64
- | top | Slot above default buttons |
65
- | control-zoom-in | Zoom-in btn |
66
- | control-zoom-out | Zoom-out btn |
67
- | control-fit-view | Fit-view btn |
68
- | control-interactive | Interaction btn |
69
- | default | Slot below default buttons |
98
+ | Name | Definition | Props |
99
+ | ---------------------| ----------------------------| ---------------------------------------------------------------------------------------------------------------------|
100
+ | top | Slot above default buttons | [ ControlsSlotProps] ( /typedocs/interfaces/ControlsSlotProps ) |
101
+ | control-item | Each control btn | [ ControlItemSlotProps] ( /typedocs/interfaces/ControlItemSlotProps ) |
102
+ | control-zoom-in | Zoom-in btn | { disabled: boolean; zoomIn: () \= > any; icon: Component } |
103
+ | control-zoom-out | Zoom-out btn | { disabled: boolean; zoomOut: () \= > any; icon: Component } |
104
+ | control-fit-view | Fit-view btn | { fitView: () \= > any; icon: Component } |
105
+ | control-interactive | Interaction btn | { interactive: boolean; toggleInteractive: () \= > any; icon: Component; lockIcon: Component; unlockIcon: Component } |
106
+ | default | Slot below default buttons | [ ControlsSlotProps] ( /typedocs/interfaces/ControlsSlotProps ) |
70
107
71
108
### Icons
72
109
@@ -77,5 +114,3 @@ import '@vue-flow/controls/dist/style.css'
77
114
| icon-fit-view | Fit-view icon |
78
115
| icon-lock | Interaction locked icon |
79
116
| icon-unlock | Interaction unlocked icon |
80
-
81
-
0 commit comments