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-js-tooltips

v1.2.1

Published

A powerful and flexible ReactJS library for adding customizable tooltips to your web application.

Readme

react-js-tooltips

A powerful and flexible ReactJS library for adding customizable tooltips to your web application.

npm version typescript GitHub license downloads min size min zip size

Features

  • Simple and intuitive API
  • Customizeable - colors, positions, animations
  • Responsive design with automatic positioning
  • Smart pointer placement
  • TypeScript support
  • Lightweight and performant
  • Programmatic control via TooltipManager

Installation

npm install react-js-tooltips

Quick Start

1. Add TooltipContainer to your app

Place TooltipContainer at the root level of your React app's tree:

import React from 'react';
import { TooltipContainer } from 'react-js-tooltips';

function App() {
  return (
    <div className='App'>
      {/* Your app content */}
      <header className='App-header'>
        <TooltipDemo />
      </header>
      <TooltipContainer />
    </div>
  );
}

2. Basic Usage with TooltipWrapper

DemoBasic

import React from "react";
import { TooltipWrapper, Tooltip } from "react-js-tooltips";

export const TooltipDemo: React.FC = () => {
  return (
    <div
      style={{
        display: "flex",
        flex: 1,
        justifyContent: "center",
        alignItems: "center",
      }}
    >
      <div>
        <TooltipWrapper
          renderOverlay={(tooltipProps: any) => {
            return (
              <Tooltip {...tooltipProps} width={240}>
                <div>
                  <h3>Tooltip Title</h3>
                  <p>This is a tooltip with some content.</p>
                </div>
              </Tooltip>
            );
          }}
        >
          <button
            style={{
              margin: 10,
              backgroundColor: "#1675e0",
              color: "white",
              padding: 10,
              border: "none",
              borderRadius: "6px",
              cursor: "pointer",
              fontSize: "16px",
            }}
          >
            CLICK ME!
          </button>
        </TooltipWrapper>
      </div>
    </div>
  );
};

3. Programmatic Control with TooltipManager

DemoClick

You can control tooltips programmatically using the TooltipManager:

import React from "react";

import {
  TooltipWrapper,
  Tooltip,
  useTooltipManager,
  TooltipTriggerType,
} from "react-js-tooltips";

export const TooltipDemo: React.FC = () => {
  const tooltipManager = useTooltipManager();
  const TOOLTIP_ID = "my-tooltip";

  return (
    <div
      style={{
        display: "flex",
        flexDirection: "column",
        flex: 1,
        justifyContent: "center",
        alignItems: "center",
      }}
    >
      <TooltipWrapper
        uniqueId={TOOLTIP_ID}
        triggerType={TooltipTriggerType.CODE}
        renderOverlay={(tooltipProps: any) => {
          return (
            <Tooltip {...tooltipProps} width={240}>
              <div>
                <h3>Tooltip Title</h3>
                <p>This is a tooltip with some content.</p>
              </div>
            </Tooltip>
          );
        }}
      >
        <div
          style={{
            color: "white",
            fontSize: 18,
            fontWeight: 500,
            padding: 5,
          }}
        >
          Tooltip is being displayed here
        </div>
      </TooltipWrapper>
      <button
        style={{
          marginTop: 50,
          backgroundColor: "#1675e0",
          color: "white",
          padding: "10px 18px",
          border: "none",
          borderRadius: "6px",
          cursor: "pointer",
          fontSize: "16px",
        }}
        onClick={() => {
          // Activates a tooltip with the given uniqueId
          tooltipManager.activateAwaitingTooltip(TOOLTIP_ID);
        }}
      >
        CLICK TO SHOW A TOOLTIP
      </button>
    </div>
  );
};

API Reference

TooltipWrapper Props

| Prop | Type | Description | |------|------|-------------| | children | React.ReactNode | The element that triggers the tooltip to be visible by click. Required. | | renderOverlay | TRenderOverlayFunction | Renders tooltip content (Tooltip component and its content). Required. | | triggerType | TooltipTriggerType | How the tooltip is triggered - programmatically or by click (CODE | CLICK). Default: CLICK | | uniqueId | string | Unique identifier for the tooltip (required when triggerType is CODE). | | blocker | boolean | If true, a tooltip won't be closed by clicking backdrop. Default: false | | backdropColor | string | Background color of the tooltip backdrop. Default: rgba(0,0,0,0.01) | | disableAnimation | boolean | Disable fade animations. Default: false | | className | string | Custom CSS class for the wrapper element. | | onClose | () => void | Callback when tooltip closes. | | onOpen | () => void | Callback when tooltip opens. | | onTargetClick | () => void | Callback when target element is clicked. |

Tooltip Props

| Prop | Type | Description | |------|------|-------------| | children | React.ReactNode | Tooltip content. Required. | | target | TTooltipTarget | Ref to the target element (provided by renderOverlay). Required. | | preferredPlacement | TooltipPlacement | Preferred position for a tooltip. | | width | number | Fixed width for the tooltip. | | pointer | boolean | Show pointer arrow. Default: true | | forcePointer | boolean | Set to false to hide a tooltip's pointer / anchor. Default: true | | backgroundColor | string | Background color of the tooltip. Default: #E8EEF7 | | borderRadius | number | Border radius of the tooltip. Default: 5 | | containerMaxWidth | number | Maximum width of the tooltip container. Default: 400 | | containerMaxHeight | number | Maximum height of the tooltip container. Default: 600 |

TooltipPlacement Enum

Available placement options:

enum TooltipPlacement {
  TOP = 'top',
  LEFT = 'left',
  BOTTOM = 'bottom',
  RIGHT = 'right',
  
  TOP_LEFT = 'top-left',
  TOP_RIGHT = 'top-right',
  BOTTOM_LEFT = 'bottom-left',
  BOTTOM_RIGHT = 'bottom-right',
  
  LEFT_TOP = 'left-top',
  LEFT_BOTTOM = 'left-bottom',
  RIGHT_TOP = 'right-top',
  RIGHT_BOTTOM = 'right-bottom',
  
  NONE = 'none'
}

TooltipTriggerType Enum

enum TooltipTriggerType {
  CLICK = 'click',  // Triggered by clicking the element
  CODE = 'code'     // Triggered programmatically
}

TooltipManager Methods

| Method | Parameters | Description | |--------|------------|-------------| | add | tooltip: Omit<ITooltipInner, 'id'> | Adds / displays a new tooltip | | remove | {id: number, uniqueId?: string} | Removes / closes a specific tooltip | | removeByUniqueId | uniqueId: string | Removes / closes tooltip by its unique ID | | removeAll | - | Removes / closes all active tooltips | | reset | - | Resets the tooltip manager (alias for removeAll) | | getActiveTooltips | - | Returns all active tooltips | | getAwaitingTooltips | - | Returns all awaiting tooltips | | addAwaitingTooltip | tooltip: Omit<ITooltipInner, 'id'> | Adds tooltip to waiting list (for CODE triggerType) | | activateAwaitingTooltip | uniqueId: string | Activates an awaiting tooltip (for CODE triggerType) | | removeAwaitingTooltip | uniqueId: string | Removes an awaiting tooltip so it can't be triggered anymore | | isAwaitingTooltipActive | uniqueId: string | Returns true if a waiting tooltip is active |

Styling

The library includes default styles and animations. You can customize tooltips using Tooltip component props. Refer "Tooltip Props" section above.

Sandbox & Demo

Check out the sandbox and live demo to see all features in action:

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📄 License

MIT © Vladislav Egorlitskii