0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Vue3&Vuetify3でdisabledにしたボタンでTooltipを表示する

Posted at

やりたいこと

disabled(グレーアウト)させたボタンにホバーした際に、なぜそのボタンが利用できないのか説明するtooltipを表示させたい

意外とvue3, vuetify3で実現させる方法がさっと見つからなかったのでメモ。

課題

以下のような単純なコードで実装すると、
tooltipもdisableになってしまい、表示されなくなってしまう

<v-tooltip location="bottom" :disabled="!isChecked">
  <template v-slot:activator="{ props }">
     <v-btn v-bind="props" :disabled="isChecked">
     送信
     </v-btn>
    </template><span>まずチェックを入れてください</span>
</v-tooltip>

結論

ボタンを他のtagでラップする(divやspanなど)

<v-tooltip location="bottom" :disabled="!isChecked">
  <template v-slot:activator="{ props }">
      <span v-bind="props">
         <v-btn :disabled="isChecked">
         送信
         </v-btn></span> 
    </template><span>まずチェックを入れてください</span>
</v-tooltip>

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?