Vue.js Component For Tippy.js Tooltip Library

Description:

A Vue.js 3/2 wrapper for the popular Tippy.js library, which is a lightweight, pure JavaScript tooltip library.

How to use it:

1. Install and import the vue-tippy.

import { createApp } from 'vue'
import VueTippy from 'vue-tippy'
// or
import { plugin as VueTippy } from 'vue-tippy'
import 'tippy.js/dist/tippy.css' // optional for styling
const app = createApp({})
app.use(
  VueTippy,
  // optional
  {
    directive: 'tippy', // => v-tippy
    component: 'tippy', // => <tippy/>
    componentSingleton: 'tippy-singleton', // => <tippy-singleton/>
  }
)
app.mount('#app')

2. Attach a tooltip to an element.

<!--  As A Directive -->
<template>
  <button v-tippy="{ content: 'Hi!' }">Tippy!</button>
</template>
<script>
  import { directive } from 'vue-tippy'
  export default {
    directives: {
      tippy: directive,
    },
  }
</script>
<!-- As A Component -->
<template>
  <tippy content="Hi!">
    <button>Tippy!</button>
  </tippy>
  <tippy>
    <button>Tippy!</button>
    <template #content>
      Hi!
    </template>
  </tippy>
</template>
<script>
  import { Tippy } from 'vue-tippy'
  export default {
    components: [Tippy],
  }
</script>
// Using composition api
import { defineComponent, ref, h } from 'vue'
import { useTippy } from 'vue-tippy'
export default defineComponent({
  setup() {
    const button = ref()
    useTippy(button, {
      content: 'Hi!',
    })
    return () => h('button', { ref: button }, 'Tippy!')
  },
})

3. All default props.

a11y: true,
allowHTML: true,
animateFill: true,
arrow: false,
flip: true,
flipOnUpdate: false,
followCursor: false,
hideOnClick: true,
ignoreAttributes: false,
inertia: false,
interactive: false,
lazy: true,
multiple: false,
showOnInit: false,
sticky: false,
touch: true,
touchHold: false,
// shift-away, shift-toward, scale, perspective
animation: 'shift-away',
appendTo: () => document.body,
aria: 'describedby',
arrowType: 'sharp',
boundary: 'scrollParent',
content: '',
delay: 0,
distance: 10,
duration: [325, 275],
flipBehavior: 'flip',
interactiveBorder: 2,
interactiveDebounce: 0,
maxWidth: 350,
offset: 0,
onHidden() {},
onHide() {},
onMount() {},
onShow() {},
onShown() {},
placement: 'top',
popperOptions: {},
role: 'tooltip',
size: 'regular',
target: '',
// light, light-border, material, translucent
theme: 'dark',
trigger: 'mouseenter focus',
updateDuration: 0,
wait: null,
zIndex: 9999,

Preview:

Vue.js Component For Tippy.js Tooltip Library

Changelog:

11/14/2021

  • v4.13.0: Directive string support

10/03/2021

  • v4.12.0: Add support to have an arrow modifier; Add string support

09/07/2021

  • v4.11.0: Add modifier to work for placement

06/16/2021

  • v4.10.2: fixed content prop on tippy component isn’t dynamic

05/11/2021

  • v4.10.1: fixed onShown and onHidden option not working

04/04/2021

  • v4.10.0: update

03/06/2021

  • v4.8.0: add tippy index without styles

10/03/2020

  • v4.7.1: Error with data attribute – `dataTestId` is not a valid option

08/17/2020

  • v4.7.0: Downgrade rollup-plugin-vue

08/08/2020

  • v4.6.0: Vetur support

07/08/2020

  • v4.5.0: Remove title attribute to prevent browser native tooltip

02/02/2020

  • v4.4.0: use parent element as trigger if trigger slot not used or target not provided.

Download Details:

Author: KABBOUCHI

Live Demo: https://kabbouchi.github.io/vue-tippy/

Download Link: https://github.com/KABBOUCHI/vue-tippy/archive/master.zip

Official Website: https://github.com/KABBOUCHI/vue-tippy

Install & Download:

# Vue 2
$ npm i vue-tippy

# Vue 3
$ npm i [email protected]

You Might Be Interested In:

Add Comment