Vue UI Components Documentation
The Vue Button displays a clickable button with text, an image or both. This guide adds the Vue Button (jqxButton) to an app, then shows how to set its options, handle its events and call its methods.
jqwidgets-scriptsjqwidgets-scripts/jqwidgets-vue3/vue_jqxbutton.vue 
In a Vue 3 project (to start one, see Getting started with Vue), add the package:
npm install jqwidgets-scripts
import JqxButton from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxbutton.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>
<div>
<div style="margin-top: 20px">
<JqxButton
ref="button"
:width="120"
:height="40"
:textPosition="'center'"
v-on:click="buttonClicked()"
>
Button
</JqxButton>
</div>
<div style="margin-top: 20px">
<JqxButton
ref="submitButton"
:width="120"
:height="40"
:textPosition="'center'"
v-on:click="submitButtonClicked()"
>
Submit
</JqxButton>
</div>
<div style="margin-top: 20px">
<JqxButton
ref="imageButton"
:width="120"
:height="40"
:textPosition="'center'"
:imgSrc="'https://www.jqwidgets.com/vue/images/facebook.png'"
v-on:click="imageButtonClicked()"
>
</JqxButton>
</div>
<div style="margin-top: 20px">
<JqxButton
ref="myTextImageButton"
:width="120"
:height="40"
:textImageRelation="'imageBeforeText'"
:textPosition="'left'"
:imgSrc="'https://www.jqwidgets.com/vue/images/twitter.png'"
v-on:click="textImageButtonClicked()"
>
Button
</JqxButton>
</div>
<div style="margin-top: 20px">
<JqxButton
ref="myHTMLButton"
:width="120"
:height="40"
:textPosition="'center'"
v-on:click="hTMLButtonClicked()"
>
<span style="font-weight: bold">HTML Button</span>
</JqxButton>
</div>
<div style="margin-top: 20px">
<JqxButton
ref="disabledButton"
:width="120"
:height="40"
:textPosition="'center'"
:disabled="true"
>
Disabled
</JqxButton>
</div>
<div style="margin-top: 1em">Events:</div>
<div ref="events"></div>
</div>
</template>
<script setup>
import { ref } from 'vue';
import JqxButton from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxbuttons.vue';
const events = ref(null);
const myTextImageButton = ref(null);
const myHTMLButton = ref(null);
function buttonClicked() {
events.value.innerHTML = '<span>Button Clicked</span>';
}
function submitButtonClicked() {
events.value.innerHTML = '<span>Submit Button Clicked</span>';
}
function imageButtonClicked() {
events.value.innerHTML = '<span>Image Button Clicked</span>';
}
function textImageButtonClicked() {
events.value.innerHTML = '<span>Text/Image Button Clicked</span>';
myTextImageButton.value.textImageRelation = 'textBeforeImage';
myTextImageButton.value.imgPosition = 'left';
myTextImageButton.value.textPosition = 'center';
}
function hTMLButtonClicked() {
events.value.innerHTML = '<span>HTML Button Clicked</span>';
myHTMLButton.value.textPosition = 'top';
myHTMLButton.value.value =
"<span style='font-style: italic; position: relative; right: 8px'>Thanks for clicking me!</span>";
}
</script>
<style></style>Options are attributes. Bind values from the script with :, for example :width="850".
Listen to an event with @ and its name. For example, click: This event is triggered when the button is clicked.
<script setup>
function onClick(event) {
console.log(event.args);
}
</script>
<template>
<JqxButton @click="onClick" />
</template>
Call methods through a template ref. For example, val: Sets or gets the value.
<script setup>
import { ref, onMounted } from 'vue';
const myButton = ref(null);
onMounted(() => {
const value = myButton.value.val('New Text');
console.log(value);
});
</script>
<template>
<JqxButton ref="myButton" />
</template>
Every component also has setOptions({ … }) and getOptions('name').