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 🙏

© 2026 – Pkg Stats / Ryan Hefner

ez-tip

v0.2.2

Published

A lightweight, zero-dependency JavaScript tooltip library that uses CSS custom properties for full styling flexibility. Tooltips can be triggered on hover or displayed permanently, with configurable delay, offset, and positioning.

Readme

ez-tip

npm GitHub issues License npm

A lightweight, zero-dependency JavaScript tooltip library that uses CSS custom properties for full styling flexibility. Tooltips can be triggered on hover or displayed permanently, with configurable delay, offset, and positioning.

DEMO

Features

  • Easy to integrate: Just import the JS and call render()
  • CSS variables for styling: Customize colors, padding, radii, and offsets without touching the JS
  • Configurable delay: Set a show delay per-instance or globally
  • Hover lock mode: Can be configured to keep the tooltip open when it is hovered
  • Smart positioning: Automatically chooses the best placement (top, bottom, left, right) or honors your preference
  • Auto-update: Repositions on scroll/resize/element resize
  • Auto-cleanup: Removes tooltips when their target elements are removed from the DOM

Installation

Install via npm/yarn:

npm install ez-tip
# or
yarn add ez-tip

Note: This library ships only JS. You must provide minimal CSS in your project to style the tooltip using the CSS variables defined below.

Quick Start

  1. Import and call render()

    import { render } from "ez-tip";
    
    // Optional: pass a global debounce delay (ms) for repositioning
    render({ delay: 100 });
  2. Add data-ez-tip to any element

    <button data-ez-tip="Hello, world!">Hover me</button>
  3. Provide CSS to style the tooltip

    /* e.g. in your global stylesheet */
    :root {
      --tooltip-arrow-size: 6px;
    }
    
    .ez-tip {
      background-color: var(--ez-tooltip-background-color);
      color: var(--ez-tooltip-color);
      padding: var(--ez-tooltip-padding);
      border-radius: var(--ez-tooltip-border-radius);
      opacity: 0;
      transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;
    }
    
    .ez-tip.ez-tip-visible {
      opacity: 1;
    }
    
    .ez-tip::after {
      content: "";
      position: absolute;
      width: 0;
      height: 0;
      border-style: solid;
    }
    
    /* ─── TOP placement ───
     Tooltip sits above the element,
     arrow on the bottom edge pointing DOWN toward the element */
    .ez-tip[data-position="top"]::after {
      bottom: calc(-1 * var(--tooltip-arrow-size));
      left: 50%;
      transform: translateX(-50%);
      border-width: var(--tooltip-arrow-size) var(--tooltip-arrow-size) 0 var(--tooltip-arrow-size);
      border-color: var(--ez-tooltip-background-color) transparent transparent transparent;
    }
    
    /* ─── BOTTOM placement ───
     Tooltip sits below the element,
     arrow on the top edge pointing UP toward the element */
    .ez-tip[data-position="bottom"]::after {
      top: calc(-1 * var(--tooltip-arrow-size));
      left: 50%;
      transform: translateX(-50%);
      border-width: 0 var(--tooltip-arrow-size) var(--tooltip-arrow-size) var(--tooltip-arrow-size);
      border-color: transparent transparent var(--ez-tooltip-background-color) transparent;
    }
    
    /* ─── LEFT placement ───
     Tooltip sits to the left of the element,
     arrow on the right edge pointing RIGHT toward the element */
    .ez-tip[data-position="left"]::after {
      right: calc(-1 * var(--tooltip-arrow-size));
      top: 50%;
      transform: translateY(-50%);
      border-width: var(--tooltip-arrow-size) 0 var(--tooltip-arrow-size) var(--tooltip-arrow-size);
      border-color: transparent transparent transparent var(--ez-tooltip-background-color);
    }
    
    /* ─── RIGHT placement ───
     Tooltip sits to the right of the element,
     arrow on the left edge pointing LEFT toward the element */
    .ez-tip[data-position="right"]::after {
      left: calc(-1 * var(--tooltip-arrow-size));
      top: 50%;
      transform: translateY(-50%);
      border-width: var(--tooltip-arrow-size) var(--tooltip-arrow-size) var(
          --tooltip-arrow-size
        ) 0;
      border-color: transparent var(--ez-tooltip-background-color) transparent transparent;
    }

API

render(options?: EzTipOptions)

Initializes tooltips for all elements with data-ez-tip. The library listens to the ready state of the dom.

  • options.delay?number
    • Global debounce delay (in ms) for repositioning on scroll/resize.
    • Default: 0
interface EzTipOptions {
  delay?: number;
}

Configuration

Before or after calling render(), you can override default styles globally by setting CSS variables on the <body> (or any ancestor):

| Variable | Default | Description | | ------------------------------- | ---------- | ------------------------------- | | --ez-tooltip-background-color | #FFFFFF | Tooltip background color | | --ez-tooltip-color | #1A1A1A | Tooltip text color | | --ez-tooltip-padding | 0 0.5rem | Tooltip padding (CSS shorthand) | | --ez-tooltip-border-radius | 3px | Tooltip border radius |

// in JS before `render()` or anytime later
document.body.style.setProperty("--ez-tooltip-background-color", "#222");
document.body.style.setProperty("--ez-tooltip-offset", "12px");
// or import the config object and change the values directly:

import { render, config } from "ez-tip";

config.backgroundColor = "#E1E5E8";
config.color = "#4A4A4A";
config.padding = "0 0.5rem";
config.borderRadius = "5px";

Data Attributes

| Attribute | Type | Default | Description | | --------------------------- | ----------------------------- | ------- | ---------------------------------------------------------------------------------- | | data-ez-tip | string | | Required. HTML content or text for the tooltip. | | data-ez-tip-hover | true or false | true | If false, tooltip is always visible; if true (or absent), shows on hover only. | | data-ez-tip-delay | number (ms) | 0 | Milliseconds to wait after hover before showing the tooltip. | | data-ez-tip-position | top,bottom,left,right | | Preferred placement; library will auto-fallback to best-fit if it doesn’t fit. | | data-ez-tip-background | string | | Force background color for a single tooltip | | data-ez-tip-color | string | | Force text color for a single tooltip | | data-ez-tip-padding | string | | Force padding for a single tooltip | | data-ez-tip-border-radius | string | | Force border-radius for a single tooltip | | data-ez-tip-hover-lock | true or false | false | If true, keeps the tooltip open when it is hovered |

<button
  data-ez-tip="Detailed info"
  data-ez-tip-hover="true"
  data-ez-tip-delay="300"
  data-ez-tip-offset="10"
  data-ez-tip-position="bottom"
>
  Show at bottom on hover with a 300ms delay
</button>

Examples

Basic tooltip

<button data-ez-tip="Simple tooltip">Hover me</button>

Tooltip with delay and custom offset

<button data-ez-tip="Delayed" data-ez-tip-delay="500" data-ez-tip-offset="16">
  Delayed tooltip
</button>

Always-visible tooltip

<p data-ez-tip="Persistent" data-ez-tip-hover="false">Persistent tooltip</p>

Hoverable tooltip

If the content of your tooltip should be selectable, it is possible to lock it on hover:

<p data-ez-tip="I'm locked on hover" data-ez-tip-hover-lock>
  Hoverable tooltip
</p>

Cleanup

Tooltips auto-remove themselves if their target element is removed from the DOM—no memory leaks or orphan nodes.

License

MIT © Alec Lloyd Probert