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

zero-tooltip

v1.2.2

Published

Tooltip component

Downloads

30

Readme

zero-tooltip   npm

zero-tooltip is a Vue 3 simple tooltip component for displaying information text when hovering over element.

About

The component is designed to enhance user interactions by providing informative tooltips when hovering over specific element by rendering overlay with given text next to it. Components settings are fully customizable.

Install

# npm
npm install zero-tooltip

# yarn
yarn add zero-tooltip

# pnpm
pnpm install zero-tooltip

Register plugin and import styles in main.ts:

import ZeroTooltip from 'zero-tooltip'
import 'zero-tooltip/style.css'

const app = createApp(App)

app.use(ZeroTooltip)

Usage

Tooltip can be used with directive v-tooltip added on elements. The given value is displayed as tooltip's text:

<button v-tooltip="'Submits this form'">Submit</button>

Zero dependencies

This component does not depend on any other package, except Vue 3

Customization

Default position for tooltip is above/on top of the element that is being hovered. You can change position by passing argument to directive:

<button v-tooltip:right="'Submits this form'">Submit</button>

Acceptable arguments are: left | top | right | bottom. This will override tooltip default position that was set during plugin registering process.

You can also define default position globally when registering plugin:

app.use(ZeroTooltip, {
    defaultPosition: 'right'
})

Tooltip component is fully customizable by giving config object as options when registering tooltip plugin:

import ZeroTooltipConfig from 'zero-tooltip'

const tooltipConfig: ZeroTooltipConfig = {
    appendTo: ... ,
    defaultPosition: ... ,
    positions: ... ,
    offsetFromSource: ... ,
    offsetFromViewport: ... ,
    minWidth: ... ,
    maxWidth: ... ,
    tooltipBorderWidth: ... ,
    tooltipClasses: ... ,
    textClasses: ... ,
    arrowSize: ... ,
    arrowClasses: ... ,
    arrowMinOffsetFromTooltipCorner: ... ,
    zIndex: ...
}

app.use(ZeroTooltip, tooltipConfig)

All above settings are optional.

Tooltip can be customizable also for each usage (locally) using same config as follows:

<template>
    <button v-tooltip:right="tooltipConfig">Submit</button>
</template>

<script setup lang="ts">
import ZeroTooltipLocalConfig from 'zero-tooltip'

const tooltipConfig: ZeroTooltipLocalConfig = reactive({
    content: 'This is tooltip',
    appendTo: ... ,
    defaultPosition: ... ,
    positions: ... ,
    offsetFromSource: ... ,
    offsetFromViewport: ... ,
    minWidth: ... ,
    maxWidth: ... ,
    tooltipBorderWidth: ... ,
    tooltipClasses: ... ,
    textClasses: ... ,
    arrowSize: ... ,
    arrowClasses: ... ,
    arrowMinOffsetFromTooltipCorner: ... ,
    zIndex: ... ,
    show: ...
})
</script>

ZeroTooltipConfig

| Property | Default value | Type | Details | |---|---|---|---| | appendTo | body | string | A valid CSS query selector to specify where Tooltip gets appended. | | defaultPosition | top | TooltipPosition | Position of tooltip component relative to element that is being hovered. | | positions | {   left: ['left', 'right', 'top', 'bottom'],   top: ['top', 'bottom', 'right', 'left'],   right: ['right', 'left', 'top', 'bottom'],   bottom: ['bottom', 'top', 'right', 'left'], } | TooltipPositions | Ordered list of fallback positions in case tooltip does not have enough space in default position. If none of given positions will have enough space for tooltip, then it will not be rendered. | | offsetFromSource | 10 | number | Tooltip offset in px from element that's being hovered (arrow size is not added to this value) | | offsetFromViewport | 20 | number | Minimal allowed tooltip offset in px from viewport sides | | minWidth | 100 | number | Minimal tooltip width in px that will be allowed to render | | maxWidth | 250 | number | Maximal tooltip width in px that will be allowed to render | | tooltipBorderWidth | 0 | number | Tooltip container border width in px | | tooltipClasses | undefined | string | List of classes that will be added to tooltip element |
| textClasses | undefined | string | List of classes that will be added to text element | | arrowSize | 5 | number | Length of arrow hypotenuse in px (arrow is generated using border width property, creating square which gets divided in four triangles, thus arrowSize is length of square side) | | arrowClasses | undefined | string | List of classes that will be added to arrow element | | arrowMinOffsetFromTooltipCorner | 6 | number | Minimal allowed arrow offset in px from tooltip corner. Used in situations when tooltip does not have enough space to be centered relative to element that is being hover, thus arrow is rendered closer to one of the tooltip corners | | zIndex | 1 | number | string | z-index css property value of tooltip |

ZeroTooltipLocalConfig

Same as ZeroTooltipConfig with following additions: | Property | Default value | Type | Details | |---|---|---|---| | content | undefined | string | REQUIRED. Tooltip text. Text is rendered as HTML, thus it's possible to give simple HTML structure, e.g., <h1>Tooltip text</h1> | | show | true | boolean | Define whether to show or not to show tooltip |

License

The license is MIT, so any extension, forking is welcome. zero-tooltip is designed as fully customizable, zero dependency, simple tooltip for Vue.js.