-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTooltip.vue
More file actions
39 lines (36 loc) · 924 Bytes
/
Copy pathTooltip.vue
File metadata and controls
39 lines (36 loc) · 924 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<script setup lang="ts">
import { useVueltip } from '@vingy/vueltip'
import { useTemplateRef } from 'vue'
const tooltipElement = useTemplateRef('tooltipElement')
const arrowElement = useTemplateRef('arrowElement')
const { tooltipStyles, arrowStyles, show, content } =
useVueltip({
tooltipElement,
arrowElement,
offset: 8,
padding: 8,
})
</script>
<template>
<!-- v-show also works -->
<div
v-if="show"
ref="tooltipElement"
class="relative isolate"
:style="[tooltipStyles]"
>
<div
ref="arrowElement"
class="pointer-events-none absolute z-0 bg-slate-100"
:style="[arrowStyles]"
/>
<div
class="relative z-10 rounded bg-slate-100 px-2 py-1 text-sm font-semibold text-slate-900 shadow-lg"
>
{{ content?.text }}
<span v-if="content?.custom">
{{ JSON.stringify(content.custom) }}</span
>
</div>
</div>
</template>