@@ -35,15 +35,51 @@ import '@vue-flow/controls/dist/style.css'
3535</template>
3636```
3737
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+ ```
3874
3975## [ Props] ( /typedocs/interfaces/ControlProps )
4076
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 |
4783| fitViewParams | Params to use on fit-view button click | [ FitViewParams] ( /typedocs/type-aliases/FitViewParams ) | true | - |
4884
4985## Emits
@@ -59,14 +95,15 @@ import '@vue-flow/controls/dist/style.css'
5995
6096### Control Buttons
6197
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 ) |
70107
71108### Icons
72109
@@ -77,5 +114,3 @@ import '@vue-flow/controls/dist/style.css'
77114| icon-fit-view | Fit-view icon |
78115| icon-lock | Interaction locked icon |
79116| icon-unlock | Interaction unlocked icon |
80-
81-
0 commit comments