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 🙏

© 2024 – Pkg Stats / Ryan Hefner

uiatar-react-tooltip

v3.2.6

Published

react tooltip component

Downloads

3

Readme

react-tooltip

Version js-standard-style npm download Build Status

Installation

npm install react-tooltip

Usage

Using NPM

1 . Require react-tooltip after installation

import ReactTooltip from 'react-tooltip'

2 . Add data-tip = "your placeholder" to your element

<p data-tip="hello world">Tooltip</p>

3 . Including react-tooltip component

<ReactTooltip />

Standalone

You can import node_modules/react-tooltip/standalone/react-tooltip.min.js into your page, please make sure that you have already imported react and react-dom into your page.

Options

Notes:

  • The tooltip is using type: dark place: top effect: float as default attribute, you don't have to add these options if you don't want to change default
  • The option you set on <ReactTooltip /> component will be implemented on every tooltip in a same page: <ReactTooltip effect="solid" />
  • The option you set on specific element, for example: <a data-type="warning"></a> will only make effect on this specific tooltip

Check example: React-tooltip Test

Global|Specific |Type |Values | Description |:---|:---|:---|:---|:---- place | data-place | String | top, right, bottom, left | placement type | data-type | String | success, warning, error, info, light | theme effect| data-effect | String | float, solid | behaviour of tooltip event | data-event | String | e.g. click | custom event to trigger tooltip eventOff | data-event-off | String | e.g. click | custom event to hide tooltip (only makes effect after setting event attribute) globalEventOff | | String| e.g. click| global event to hide tooltip (global only) isCapture | data-iscapture | Bool | true, false | when set to true, custom event's propagation mode will be capture offset | data-offset | Object | top, right, bottom, left | data-offset="{'top': 10, 'left': 10}" for specific and offset={{top: 10, left: 10}} for global multiline | data-multiline | Bool | true, false | support <br>, <br /> to make multiline className | data-class | String | | extra custom class, can use !important to overwrite react-tooltip's default class html | data-html | Bool | true, false | <p data-tip="<p>HTML tooltip</p>" data-html={true}></p> or <ReactTooltip html={true} /> delayHide | data-delay-hide | Number | | <p data-tip="tooltip" data-delay-hide='1000'></p> or <ReactTooltip delayHide={1000} /> delayShow | data-delay-show | Number | | <p data-tip="tooltip" data-delay-show='1000'></p> or <ReactTooltip delayShow={1000} /> insecure | null | Bool | true, false | Whether to inject the style header into the page dynamically (violates CSP style-src but is a convenient default) border | data-border | Bool | true, false | Add one pixel white border getContent | null | Func or Array | () => {}, [() => {}, Interval] | Generate the tip content dynamically afterShow | null | Func | () => {} | Function that will be called after tooltip show afterHide | null | Func | () => {} | Function that will be called after tooltip hide disable | data-tip-disable | Bool | true, false | Disable the tooltip behaviour, default is false scrollHide | data-scroll-hide | Bool | true, false | Hide the tooltip when scrolling, default is true resizeHide | null | Bool | true, false | Hide the tooltip when resizing the window, default is true wrapper | null | String | div, span | Selecting the wrapper element of the react tooltip, default is div

Using react component as tooltip

Check the example React-tooltip Test

Note:
  1. data-tip is necessary, because <ReactTooltip /> find tooltip via this attribute
  2. data-for correspond to the id of <ReactTooltip />
  3. When using react component as tooltip, you can have many <ReactTooltip /> in a page but they should have different id

Static Methods

###ReactTooltip.hide(target)

Hide the tooltip manually, the target is optional, if no target passed in, all exitent tooltip will be hiden

import {findDOMNode} from 'react-dom'
import ReactTooltip from 'react-tooltip'

<p ref='foo' data-tip='tooltip'></p>
<button onClick={() => { ReactTooltip.hide(findDOMNode(this.refs.foo)) }}></button>
<ReactTooltip />

###ReactTooltip.rebuild()

Rebinding all tooltips

###ReactTooltip.show(target)

Show specific tooltip manually, for example:

import {findDOMNode} from 'react-dom'
import ReactTooltip from 'react-tooltip'

<p ref='foo' data-tip='tooltip'></p>
<button onClick={() => { ReactTooltip.show(findDOMNode(this.refs.foo)) }}></button>
<ReactTooltip />

Trouble Shooting

1. Using tooltip within the modal (e.g. react-modal)

The component was designed to set a <Reactooltip /> one place then use tooltip everywhere, but a lot of people stuck in using this component with modal, you can check the discussion here, the summarization of solving the problem is as following:

  1. Put <ReactTooltip /> out of the <Modal>
  2. Use ReactTooltip.rebuild() when opening the modal
  3. If your modal's z-index happens to higher than the tooltip, use the attribute className to custom your tooltip's z-index

I suggest always put <ReactTooltip /> in the Highest level or smart component of Redux, so you might need these static method to control tooltip's behaviour in some situations

2. Hide tooltip when getContent returns undefined

When you set getContent={() => { return }} you will find the tooltip will dispaly true, that's because React will set the value of data-* to be 'true' automatically if there is no value to be set. So you have to set data-tip='' in this situaction.

<p data-tip='' data-for='test'></p>
<ReactTooltip id='test' getContent={() => { return null }}/>

Same for empty children, if you don't want show the tooltip when the children is empty

<p data-tip='' data-for='test'></p>
<ReactTooltip id='test'>{}</ReactTooltip>

Article

How I insert sass into react component

License

MIT