npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tippy.vue

v3.2.1

Published

Nesting-free Vue components for Tippy.js - a drop-in addition with no structural or css changes required

Downloads

4,406

Readme

Design

  • Easy to use: A clumsy tool will wind up chronically underutilized, so Tippy.vue has been designed with a focus on ergonomics.
  • Clean to write: Writing Tippy.vue is clean. We don't use wrapper components, everything is in the default slot, and common options are exposed as props.
  • Clean HTML: Tippy.vue mounts itself and then disappears from the DOM tree, leaving your layout untouched.

Examples

<!-- As an inline directive -->
<button v-tippy="`Seconds: ${seconds}`">Counter</button>
<button v-tippy="{content: 'Some content', placement: 'right'}">Side</button>

<!-- As a component -->
<button v-tippy>Counter</button>
<tippy>Time: <i>{{seconds}}</i></tippy>

<button v-tippy:name>Props</button>
<tippy target="name" placement="right">Side tooltip</tippy>

<!-- Target the parent (useful for components adding a tooltips to themselves) -->
<button>
  Button
  <tippy target="_parent">Bound to parent</tippy>
</button>

<!-- Only the commonly-used Tippy.js options have props, but
     other niche options can be passed into the 'extra' prop -->
<button v-tippy>Follow me</button>
<tippy :extra="{followCursor: true}">Tip</tippy>

<!-- Using a singleton -->
<tippy-singleton move-transition="transform 0.1s ease-out"/>
<button v-tippy>Item 1</button> <tippy singleton>Tip 1</tippy>
<button v-tippy>Item 2</button> <tippy singleton>Tip 2</tippy>
<button v-tippy>Item 3</button> <tippy singleton>Tip 3</tippy>

More examples and working demos can be found in the documentation.

Custom Props

Tippy.vue doesn't have a vue property for every Tippy.js prop, instead providing extra for additional options. This is by design, since it keeps the API clean and easy to understand. You can however add you own props without any modifications to the base library. This is a fairly advanced feature, but it's available if needed. See the docs for an overview of the API.

Why?

There's already a popular Vue library for using Tippy.js, VueTippy, so you might (rightfully) ask, why make another one?

To put it simply, VueTippy makes a few structural concessions which I disagree with. The most significant is that when using VueTippy, adding a complex (i.e. non-directive) tooltip to an element will wrap it in a <span>, which can easily screw up a complex layout. On top of that, I find their syntax clunky and ugly. Wrapping every tooltipped component in a slot seems unnecessary.

One of my mottos is that a clumsy tool will wind up chronically underutilized, so Tippy.vue has been designed from the start with a strong focus on ergonomics. Adding a tooltip is a simple, drop-in addition, with no structural or styling changes necessary.

<!-- VueTippy -->
<tippy>
  <button>Tippy!</button>
  
  <template #content>
    Hi!
  </template>
</tippy>

<!-- Tippy.vue -->
<button v-tippy>Tippy!</button>
<tippy>Hi!</tippy>

🚀 Installation

📦 Package Manager

# npm
npm i tippy.vue

# Yarn
yarn add tippy.vue

💻 CDN

Tippy.vue doesn't bundle Tippy.js. The most up-to-date Tippy install process is explained in the Tippy docs, but as of the time of writing, these are the necessary scripts:

<!-- Development -->
<script src="https://unpkg.com/@popperjs/core@2/dist/umd/popper.min.js"></script>
<script src="https://unpkg.com/tippy.js@6/dist/tippy-bundle.umd.js"></script>

<script src="https://unpkg.com/tippy.vue@3"></script>
<!-- Production -->
<script src="https://unpkg.com/@popperjs/core@2"></script>
<script src="https://unpkg.com/tippy.js@6"></script>

<script src="https://unpkg.com/tippy.vue@3"></script>

Usage

📦 Package Manager

You can use Tippy.vue as a plugin or access the individual components directly:

// use the plugin
import {TippyPlugin} from 'tippy.vue';

app.use(TippyPlugin);
app.use(TippyPlugin, {
  tippyDefaults: {}, // convenience to set tippy.js default props
});
// or add them individually
import {TippyDirective, Tippy, TippySingleton} from 'tippy.vue';

app.directive('tippy', TippyDirective);
app.component('tippy', Tippy);
app.component('tippy-singleton', TippySingleton);

import tippy from 'tippy.js'
tippy.setDefaultProps({
  // default tippy props
});
/* add styles/themes to your global stylesheet */
@import '~tippy.js/dist/tippy.css';

You can also add them in individual components:

<template>
  <div>
    <div v-tippy>Wow</div>
    <tippy>Cool</tippy>
  </div>
</template>

<script>
import {Tippy, TippyDirective} from 'tippy.vue'

export default {
  components: {
    Tippy
  },
  directives: {
    tippy: TippyDirective
  }
}
</script>

💻 CDN

// use the plugin
app.use(TippyVue);
app.use(TippyVue, {
  tippyDefaults: {}, // convenience to set tippy.js default props
});
// or add them individually
app.directive('tippy', TippyVue.TippyDirective);
app.component('tippy', TippyVue.Tippy);
app.component('tippy-singleton', TippyVue.TippySingleton);
tippy.setDefaultProps({
  // default tippy props
});

Code Completion

Tippy.vue includes code completion files for IntelliJ IDEA, Vetur, and Volar. See the docs for details on how to use them.

Contributing

Setting up an environment is very standard. Make sure you're on the latest version of yarn, then run:

yarn install
yarn docs:dev