<link href="https://cdn.jsdelivr.net/npm/@mdi/font@5.9.55/css/materialdesignicons.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vuetify@3.1.11/dist/vuetify.min.css">
<h3>Vuetify Change Button Color if Button active or selected</h3>
<v-btn @click="changeActiveButton(1)" color="primary" :class="{ 'active-button': activeButton === 1 }">Button
<v-btn @click="changeActiveButton(2)" color="primary" :class="{ 'active-button': activeButton === 2 }">Button
<v-btn @click="changeActiveButton(3)" color="primary" :class="{ 'active-button': activeButton === 3 }">Button
<script src="https://unpkg.com/vue@3.2.21/dist/vue.global.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vuetify@3.1.11/dist/vuetify.min.js"></script>
const { createApp } = Vue;
const { createVuetify } = Vuetify;
const vuetify = createVuetify();
changeActiveButton(buttonNumber) {
if (this.activeButton === buttonNumber) {
// If the clicked button is already active, deactivate it
this.activeButton = null;
// Deactivate the previously active button
this.activeButton = buttonNumber;
background-color:#EEFF41 !important;
/* Change this to the color you want */
/* Change the text color to match the background color */