I am using Vuetify v-button-toggle
to toggle between three buttons like below. And each button has different active class. But clicking on a button does not set the active respective active class. What I am missing?
<v-btn-toggle
v-model="justify"
borderless
dense
group
class="d-flex flex-column "
>
<v-btn active-class="dnrSelected" exact>
<v-icon right class="mr-2">mdi-close</v-icon>
<span>Do Not Recommend</span>
</v-btn>
<v-btn active-class="rSelected">
<v-icon right class="mr-1">mdi-check</v-icon>
<span>Recommend</span>
</v-btn>
<v-btn active-class="srSelected">
<v-icon right class="mr-1">mdi-check-all</v-icon>
<span>Strongly Recommend</span>
</v-btn>
</v-btn-toggle>
CSS classes
<style scoped>
.dnrSelected {
background-color: #e57373;
}
.rSelected {
background-color: #c5e1a5;
}
.srSelected {
background-color: #81c784;
}
</style>
Update: As expected class is added to the button on click
<button type="button" class="v-btn srSelected v-btn--active v-btn--contained theme--light v-size--default"><span class="v-btn__content"><i aria-hidden="true" class="v-icon notranslate mr-1 v-icon--right mdi mdi-check-all theme--light"></i> <span>Strongly Recommend</span></span></button>
Update: Default Vuetify class below is overriding the custom style
.v-btn-toggle--group > .v-btn.v-btn {
background-color: transparent !important;
border-color: transparent;
margin: 4px;
min-width: auto;
}
How to override this default style class?
One workaround I have found is targeting the elements specifically in the custom CSS by giving the containing element an ID like below
And then using this
id
to specify target elements like below