Vuetify: [Feature Request] [v-btn-toggle] Disable active state

Created on 19 Feb 2020  路  3Comments  路  Source: vuetifyjs/vuetify

Problem to solve

When you click on a button of a btn-toggle it remains activated and there is no property to configure this behavior.

The workaround :
It consists in resetting the group value to null at each change

<v-btn-toggle v-model="activeButton" @change="resetActiveButton">
        <v-btn :loading="executing" @click="execute">Execute</v-btn>

        <v-menu offset-y>
          <template v-slot:activator="{ on }">
            <v-btn v-on="on">
              <v-icon>mdi-menu-down</v-icon>
            </v-btn>
          </template>

          <v-list>
            <v-list-item @click="reload">
              <v-list-item-title>Reload</v-list-item-title>
            </v-list-item>
          </v-list>
        </v-menu>
      </v-btn-toggle>
 export default {
    data() {
      return {
        activeButton: null
      }
    },
    methods: {
      resetActiveButton() {
        this.$nextTick(() => {
          this.activeButton = null
        })
      }
    }

Proposed solution

I suggest adding a property like "ignore-active-state: bool (default to false)" which would allow the group to behave like a button and not like a select

VBtnToggle feature

Most helpful comment

I ended up doing this.

      <v-item-group class="v-btn-toggle">
        <v-btn>
          <v-icon>add</v-icon>
        </v-btn>
        <v-btn>
          <v-icon>remove</v-icon>
        </v-btn>
      </v-item-group>

It applies the visual style of v-btn-toggle without changing the functionality of btns.

All 3 comments

Do you mean like #4325, that wasn't actually implemented IMHO.

4325 indeed seems to answer the problem

Ps : esynaps account is mine too

I ended up doing this.

      <v-item-group class="v-btn-toggle">
        <v-btn>
          <v-icon>add</v-icon>
        </v-btn>
        <v-btn>
          <v-icon>remove</v-icon>
        </v-btn>
      </v-item-group>

It applies the visual style of v-btn-toggle without changing the functionality of btns.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

efootstep picture efootstep  路  3Comments

SteffenDE picture SteffenDE  路  3Comments

smousa picture smousa  路  3Comments

aaronjpitts picture aaronjpitts  路  3Comments

gluons picture gluons  路  3Comments