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

react-tooltip-z

v3.0.1

Published

Lightweight, customizable React tooltip component with hover, click, focus and manual trigger support.

Readme

💬 react-tooltip-z

NPM Downloads

LIVE EXAMPLE


Lightweight, smart auto-positioned tooltip for React 18+.
Zero dependencies. Portal-based. Fully controllable.

🚀 Smart auto-positioning engine.

The tooltip dynamically calculates its position (top, right, bottom, left) and automatically adjusts when it would overflow the screen — ensuring it always remains visible inside the viewport.


Why react-tooltip-z?

  • 🧩 Simple wrapper API
  • 🪟 Rendered via React Portal (outside root)
  • 🎯 Supports hover, click, manual
  • 🎨 Fully customizable content (text / jsx / component)
  • ⚡ ForwardRef control (show, hide)
  • 📦 Lightweight & dependency-free
  • 📱 Smart auto-position (viewport aware)

Designed for flexible UI overlays and explicit control flows.


Installation

npm install react-tooltip-z

Basic Usage

import React from "react";
import { Tooltip } from "react-tooltip-z";

export function Example() {
  return (
    <Tooltip
      content={<b>This is JSX<br />Tooltip</b>}
      placement="right"
    >
      <button>Hover me</button>
    </Tooltip>
  );
}

Manual Control (ForwardRef)

import React, { useRef } from "react";
import { Tooltip } from "react-tooltip-z";

export function Example() {
  const tooltipRef = useRef(null);

  return (
    <>
      <button
        onClick={() => {
          tooltipRef.current?.show("Dynamic content");
        }}
      >
        Show Tooltip
      </button>

      <button
        onClick={() => {
          tooltipRef.current?.hide();
        }}
      >
        Show Tooltip
      </button>

      <Tooltip
        ref={tooltipRef}
        trigger="manual"
        placement="top"
      >
        <span>Target Element</span>
      </Tooltip>
    </>
  );
}

Controlled Mode (open + onOpenChange)

export function ControlledExample() {
  const [open, setOpen] = React.useState(false);

  return (
    <>
      <button onClick={() => setOpen(prev => !prev)}>
        Toggle
      </button>

      <Tooltip
        content="Controlled tooltip"
        open={open}
        onOpenChange={setOpen}
      >
        <span>Target</span>
      </Tooltip>
    </>
  );
}

Global Control (Provider API)

import { TooltipProvider, useTooltip } from "react-tooltip-z";
<TooltipProvider>
  <App />
</TooltipProvider>
const { show, hide } = useTooltip();

ForwardRef API

tooltipRef.current?.show(content?);
tooltipRef.current?.hide();

Props

| Prop | Type | Default | Description | | ------------------ | ---------------------------------------- | --------- | ------------------------------- | | children | ReactNode | — | Target element | | content | string \| ReactNode | — | Tooltip content | | placement | "top" \| "right" \| "bottom" \| "left" | "top" | Tooltip position | | trigger | "hover" \| "click" \| "manual" | "hover" | Trigger behavior | | tooltipClassName | string | — | Custom tooltip class | | backgroundColor | string | #282727 | Tooltip background color | | textColor | string | #ffffff | Tooltip text color | | constrainWidth | boolean | true | Limit max width (220px) to prevent overflow | | animation | "fade" \| "zoom" | "fade" | Tooltip animation | | delay | number | 250 | Delay before show (ms) | | arrowCentered | boolean | false | Center arrow to element | | open | boolean | — | Controlled visibility | | closeOnResize | boolean | true | Hide on window resize | | closeOnScroll | boolean | false | Hide on scroll | | onOpenChange | (boolean) => void | — | Callback after show/hide | | tagName | string | "span" | Wrap children with custom tag | | ...rest | any | — | orwarded to wrapped child element |


Behavior Notes

  • Tooltip auto-adjusts if it goes outside viewport.
  • trigger="manual" requires ref methods (show, hide) or open prop.
  • Extra props are forwarded to the wrapped child element.

Comparison

| Criteria | react-tooltip-z | Browser title | Generic Tooltip Library | |----------------------|-----------------|------------------|--------------------------| | Portal rendering | ✅ | ❌ | ✅ | | Smart auto-position | ✅ | ❌ | ⚠️ Partial | | ForwardRef API | ✅ | ❌ | ❌ | | Controlled mode | ✅ | ❌ | ⚠️ Optional | | Zero dependencies | ✅ | ⚪ Built-in | ❌ | | Custom JSX content | ✅ | ❌ | ⚠️ Partial |


License

MIT