Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-popper-tooltip

Package Overview
Dependencies
Maintainers
2
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-popper-tooltip

React tooltip library built around react-popper

  • 4.4.2
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
669K
decreased by-15.93%
Maintainers
2
Weekly downloads
 
Created

What is react-popper-tooltip?

The react-popper-tooltip package is a React wrapper for Popper.js, which is a library used to position tooltips and popovers in web applications. It provides a simple and flexible way to create tooltips that are dynamically positioned based on the user's viewport and other elements on the page.

What are react-popper-tooltip's main functionalities?

Basic Tooltip

This code demonstrates how to create a basic tooltip using the react-popper-tooltip package. The tooltip appears when the user hovers over the button.

import React from 'react';
import { usePopperTooltip } from 'react-popper-tooltip';
import 'react-popper-tooltip/dist/styles.css';

const BasicTooltip = () => {
  const { getTooltipProps, setTooltipRef, setTriggerRef, visible } = usePopperTooltip();

  return (
    <div>
      <button ref={setTriggerRef}>Hover me</button>
      {visible && (
        <div ref={setTooltipRef} {...getTooltipProps({ className: 'tooltip-container' })}>
          Tooltip content
        </div>
      )}
    </div>
  );
};

export default BasicTooltip;

Custom Tooltip

This code demonstrates how to create a custom tooltip that appears on click and is positioned to the right of the trigger element.

import React from 'react';
import { usePopperTooltip } from 'react-popper-tooltip';
import 'react-popper-tooltip/dist/styles.css';

const CustomTooltip = () => {
  const { getTooltipProps, setTooltipRef, setTriggerRef, visible } = usePopperTooltip({
    placement: 'right',
    trigger: 'click',
  });

  return (
    <div>
      <button ref={setTriggerRef}>Click me</button>
      {visible && (
        <div ref={setTooltipRef} {...getTooltipProps({ className: 'tooltip-container' })}>
          Custom Tooltip content
        </div>
      )}
    </div>
  );
};

export default CustomTooltip;

Tooltip with Arrow

This code demonstrates how to create a tooltip with an arrow using the react-popper-tooltip package. The tooltip appears when the user hovers over the button and includes an arrow pointing to the trigger element.

import React from 'react';
import { usePopperTooltip } from 'react-popper-tooltip';
import 'react-popper-tooltip/dist/styles.css';

const TooltipWithArrow = () => {
  const { getArrowProps, getTooltipProps, setTooltipRef, setTriggerRef, visible } = usePopperTooltip({
    arrow: true,
  });

  return (
    <div>
      <button ref={setTriggerRef}>Hover me</button>
      {visible && (
        <div ref={setTooltipRef} {...getTooltipProps({ className: 'tooltip-container' })}>
          Tooltip with arrow
          <div {...getArrowProps({ className: 'tooltip-arrow' })} />
        </div>
      )}
    </div>
  );
};

export default TooltipWithArrow;

Other packages similar to react-popper-tooltip

Keywords

FAQs

Package last updated on 27 Jun 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc