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 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-js-tooltips

v1.1.0

Published

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

Readme

react-js-tooltips

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

npm version GitHub license

🎯 Features

  • Simple and intuitive API
  • Highly customizable (colors, positions, animations)
  • Responsive design with automatic positioning
  • Smart pointer placement
  • TypeScript support
  • Lightweight and performant
  • Multiple placement options
  • Programmatic control via TooltipManager

📦 Installation

npm install react-js-tooltips

🚀 Quick Start

1. Add TooltipContainer to your app

Wrap your application with TooltipContainer at the root level:

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

function App() {
  return (
    <div>
      <TooltipContainer />
      {/* Your app content */}
    </div>
  );
}

2. Basic Usage with TooltipWrapper

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

function MyComponent() {
  return (
      <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>
          Click me!
        </button>
      </TooltipWrapper>
  );
}

3. Programmatic Control with TooltipManager

You can control tooltips programmatically using the TooltipManager:

import { useTooltipManager, TooltipTriggerType } from 'react-js-tooltips';

function Example() {
  const tooltipManager = useTooltipManager();

  const openTooltip = () => {
    // Activates a tooltip with the given uniqueId
    tooltipManager.activateAwaitingTooltip('my-tooltip');
  };

  return (
    <div>
      <button onClick={openTooltip}>Open Tooltip</button>
    </div>
  );
}

🔧 API Reference

TooltipWrapper Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | children | React.ReactNode | required | The element that triggers the tooltip | | renderOverlay | TRenderOverlayFunction | required | Function that returns the tooltip content (Tooltip component) | | triggerType | TooltipTriggerType | CLICK | How the tooltip is triggered (CLICK | CODE) | | uniqueId | string | undefined | Unique identifier for the tooltip (required when triggerType is CODE) | | blocker | boolean | false | If true, user must interact with tooltip before closing | | backdropColor | string | rgba(0,0,0,0.01) | Background color of the tooltip backdrop | | disableAnimation | boolean | false | Disable fade animations | | className | string | undefined | Custom CSS class for the wrapper element | | onClose | () => void | undefined | Callback when tooltip closes | | onOpen | () => void | undefined | Callback when tooltip opens | | onTargetClick | () => void | undefined | Callback when target element is clicked |

Tooltip Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | children | React.ReactNode | required | Tooltip content | | target | TTooltipTarget | required | Ref to the target element (provided by renderOverlay) | | preferredPlacement | TooltipPlacement | undefined | Preferred position for the tooltip | | width | number | undefined | Fixed width for the tooltip | | pointer | boolean | true | Show pointer arrow | | forcePointer | boolean | true | Force pointer to always be visible | | backgroundColor | string | #E8EEF7 | Background color of the tooltip | | borderRadius | number | 5 | Border radius of the tooltip | | containerMaxWidth | number | 400 | Maximum width of the tooltip container | | containerMaxHeight | number | 600 | Maximum height of the tooltip container |

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) | tooltip: Omit<ITooltipInner, 'id'> | Add a new tooltip | | remove({id, uniqueId}) | {id: number, uniqueId?: string} | Remove a specific tooltip | | removeByUniqueId(uniqueId) | uniqueId: string | Remove tooltip by unique ID | | removeAll() | - | Remove all active tooltips | | reset() | - | Reset the tooltip manager (alias for removeAll) | | getActiveTooltips() | - | Get all active tooltip configurations | | getAwaitingTooltips() | - | Get all waiting tooltip configurations | | addAwaitingTooltip(tooltip) | tooltip: Omit<ITooltipInner, 'id'> | Add tooltip to waiting list (for CODE trigger) | | activateAwaitingTooltip(uniqueId) | uniqueId: string | Activate a waiting tooltip | | removeAwaitingTooltip(uniqueId) | uniqueId: string | Remove a waiting tooltip | | isAwaitingTooltipActive(uniqueId) | uniqueId: string | Check if a waiting tooltip is active |

🎨 Styling

The library includes default styles and animations. You can customize tooltips using:

  • Props: Most styling props are available directly on the Tooltip component
  • CSS Modules: Import and override styles from the library's CSS modules
  • Inline styles: Pass custom styles through props

🌐 Demo

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

📖 Documentation

For more information, visit the GitHub repository.

🤝 Contributing

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

📄 License

MIT © Vladislav Egorlitskii