Vue UI Components Documentation
The Vue ToolBar displays a bar with tools such as buttons, drop-downs and others. This guide adds the Vue ToolBar (jqxToolBar) to an app, then shows how to set its options, handle its events and call its methods.
jqwidgets-scriptsjqwidgets-scripts/jqwidgets-vue3/vue_jqxtoolbar.vue 
In a Vue 3 project (to start one, see Getting started with Vue), add the package:
npm install jqwidgets-scripts
import JqxToolBar from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxtoolbar.vue';
import 'jqwidgets-scripts/jqwidgets/styles/jqx.base.css';
import 'jqwidgets-scripts/jqwidgets/styles/jqx.tailwind-blue-dark.css';
With <script setup>, an imported component is ready to use in the template. jqx.base.css is required; the second file is a theme, selected with the theme attribute.
The Default Functionality demo as a Single-File Component:
<template>
<JqxToolbar :width="width" :height="35" :tools="tools" :initTools="initTools"> </JqxToolbar>
</template>
<script setup>
import { ref } from 'vue';
import JqxToolbar from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxtoolbar.vue';
// The demo page's theme (set by the site's demos.js).
const theme = jqx.theme;
const width = ref('90%');
const tools = ref(
'toggleButton toggleButton toggleButton | toggleButton | dropdownlist combobox | input | custom'
);
// The icons come from jqxEditor's sprite, which is drawn in one dark colour. Used as a mask
function appendIcon(button, icon) {
button.appendChild(icon);
const style = getComputedStyle(icon);
if (style.backgroundImage === 'none') return;
icon.style.maskImage = style.backgroundImage;
icon.style.maskPosition = style.backgroundPosition;
icon.style.maskRepeat = 'no-repeat';
// its own colour, so the site's dark mode does not take the light fill for a light background
icon.style.color = 'inherit';
icon.style.setProperty('background', 'currentColor', 'important');
}
function initTools(type, index, tool, menuToolIninitialization) {
const icon = document.createElement('div');
if (type == 'toggleButton') {
icon.className =
'jqx-editor-toolbar-icon jqx-editor-toolbar-icon-' + theme + ' buttonIcon ';
}
switch (index) {
case 0:
icon.className += 'jqx-editor-toolbar-icon-bold jqx-editor-toolbar-icon-bold-' + theme;
icon.setAttribute('title', 'Bold');
appendIcon(tool[0], icon);
break;
case 1:
icon.className +=
'jqx-editor-toolbar-icon-italic jqx-editor-toolbar-icon-italic-' + theme;
icon.setAttribute('title', 'Italic');
appendIcon(tool[0], icon);
break;
case 2:
icon.className +=
'jqx-editor-toolbar-icon-underline jqx-editor-toolbar-icon-underline-' + theme;
icon.setAttribute('title', 'Underline');
appendIcon(tool[0], icon);
break;
case 3:
tool.jqxToggleButton({ width: 80, toggled: true });
tool.text('Enabled');
tool.on('click', () => {
const toggled = tool.jqxToggleButton('toggled');
if (toggled) {
tool.text('Enabled');
} else {
tool.text('Disabled');
}
});
break;
case 4:
tool.jqxDropDownList({
width: 130,
source: [
"<span style='font-family: Courier New;'>Courier New</span>",
"<span style='font-family: Times New Roman;'>Times New Roman</span>",
"<span style='font-family: Verdana;'>Verdana</span>"
],
selectedIndex: 1
});
break;
case 5:
tool.jqxComboBox({
width: 50,
source: [8, 9, 10, 11, 12, 14, 16, 18, 20],
selectedIndex: 3
});
break;
case 6:
tool.jqxInput({ width: 200, placeHolder: 'Type here to search...' });
break;
case 7:
const button = document.createElement('div');
const img = document.createElement('img');
img.src = 'https://www.jqwidgets.com/vue/images/administrator.png';
img.title = 'Custom tool';
button.appendChild(img);
tool[0].appendChild(button);
tool.jqxButton({ height: 15 });
break;
}
}
</script>
<style>
.buttonIcon {
margin: -5px 0 0 -3px;
width: 16px;
height: 17px;
}
</style>Options are attributes. Bind values from the script with :, for example :width="850".
Listen to an event with @ and its name. For example, open: This event is triggered when the minimize pop-up menu is opened.
<script setup>
function onOpen(event) {
console.log(event.args);
}
</script>
<template>
<JqxToolBar @open="onOpen" />
</template>
Call methods through a template ref. For example, refresh: Refreshes the widget.
<script setup>
import { ref, onMounted } from 'vue';
const myToolBar = ref(null);
onMounted(() => {
myToolBar.value.refresh();
});
</script>
<template>
<JqxToolBar ref="myToolBar" />
</template>
Every component also has setOptions({ … }) and getOptions('name').