LoginSignup
2
1

More than 1 year has passed since last update.

Floating VueでTooltipを作る

Posted at

Vue3でtooltipやdropdownを作成できるライブラリFloating Vueを使う機会があり
マニュアル通りだと動かず困っていたところ、
cogorさんが助けてくれたので使い方のメモ書きを共有します。
image.png

Vue.js/Tooltip.vue
<template>
  <div class="flex items-start">
    <Tooltip :placement="placement" :triggers="[trigger]" :theme="tooltipStyle">
      <a>Sponsor me</a>
      <template #popper>
        Help me fund my Open Source work!
      </template>
    </Tooltip>
  </div>
</template>

<script lang="ts" setup>
import type { PropType } from 'vue'
import type { TooltipPlacement, TooltipStyle, TooltipTrigger } from './types'
import { Tooltip } from 'floating-vue'
import 'floating-vue/dist/style.css'

const props = defineProps({
    placement: {
      type: String as PropType<TooltipPlacement>,
      default: "top"
    },
    tooltipStyle: {
      type: String as PropType<TooltipStyle>,
      default: "tooltip-dark",
    },
    trigger: {
      type: String as PropType<TooltipTrigger>,
      default: "hover"
    }
})
</script>
2
1
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
2
1