Vue Diagram - Diagram Tools
The DevExtreme Diagram ships with configurable tool panels and menus. The following image highlights these visual elements:

To configure Diagram tools, implement the following properties:
To specify which commands a tool panel or menu displays, define the element's commands[] array (for instance, mainToolbar.commands[]). To add predefined commands, specify only the name property:
- <template>
- <DxDiagram>
- <DxMainToolbar :visible="true">
- <DxCommand name="undo" />
- <DxCommand name="redo" />
- <DxCommand name="fontName" />
- <DxCommand name="fontSize" />
- <DxCommand name="bold" />
- <DxCommand name="italic" />
- <DxCommand name="underline" />
- </DxMainToolbar>
- </DxDiagram>
- </template>
- <script setup lang="ts">
- import { DxDiagram, DxMainToolbar, DxCommand } from 'devextreme-vue/diagram';
- </script>
The Diagram component supports custom commands within tool panels and menus. To define a custom command item, specify a string command.name value (different from Command type values) and implement the onCustomCommand handler. You can also specify custom command icons and text. The following code snippet demonstrates a custom command that imports an empty value into the Diagram to clear component content:
- <template>
- <DxDiagram @custom-command="handleCustomCommand">
- <DxMainToolbar :visible="true">
- <DxCommand
- name="clear"
- icon="deletetable"
- />
- </DxMainToolbar>
- </DxDiagram>
- </template>
- <script setup lang="ts">
- import { DxDiagram, DxMainToolbar, DxCommand, type DxDiagramTypes } from 'devextreme-vue/diagram'
- function handleCustomCommand(e: DxDiagramTypes.CustomCommandEvent) {
- if(e.name === 'clear') {
- e.component.import('');
- }
- }
- </script>