0.4.2 • Published 3 years ago

react-super-tooltip v0.4.2

Weekly downloads
1
License
MIT
Repository
github
Last release
3 years ago

react-super-tooltip

Version

EXAMPLE

TODO

Spott.ai - interactive videos and images

WHY ANOTHER TOOLTIP LIBRARY ?!

react-super-tooltip is made to be super simple to use, but still be very smart out of the box with default configuration. It can automatically position itself to be in the viewport by calculating the best position relative to your element (top, right, bottom, left or any 4 corners), and even when it finds perfect location it will additionally offset itself to find even better fit.

Installation

npm i react-super-tooltip

Usage

1 . Import react-super-tooltip in your code

import ReactSuperTooltip from 'react-super-tooltip'

2 . Wrap your element in <ReactSuperTooltip> component

<ReactSuperTooltip>
  <button>Hover me</button>
</ReactSuperTooltip>

3 . That's it

Options

  • Each <ReactSuperTooltip /> can have its own props which will override default behavior for that specific tooltip, for example <ReactSuperTooltip trigger="click" />
NameTypeDefaultDescription
contentNodeTooltip content
triggerStringhoverHow to trigger tooltip (Available: hover, click)
ignoreTriggerBoolfalseTooltip can be opened only manually (by calling tooltipRef.show()), trigger is ignored
preferredPositionStringrightDefine your preferred position that will be used if multiple positions are possible
interactiveBooltrueAllow mouse events on the tooltip and keep it open when hovered
componentComponentdivChoose container element
arrowSizeNumber6Tooltip arrow size
arrowColorString#fffTooltip arrow color
offsetNumber0Number of pixels to offset tooltip away from the element
boundsStringSelector or HTML element to be used as boundaries
keepInBoundsBoolfalseKeep the tooltip inside the boundaries even if it covers the target element
onShowFunctionnoopCallback function that will be called when tooltip is shown
onHideFunctionnoopCallback function that will be called when tooltip is hidden

Manually showing and hiding tooltips

tooltipRef.show()

Show the tooltip manually, for example:

import ReactSuperTooltip from 'react-super-tooltip';

<ReactSuperTooltip ref={ref => this.tooltipRef = ref}>
  <button>I'm a button</button>
</ReactSuperTooltip>

<button onClick={() => { this.tooltipRef.show() }}>Show tooltip</button>

tooltipRef.hide()

Hide the tooltip manually

import ReactSuperTooltip from 'react-super-tooltip';

<ReactSuperTooltip ref={ref => this.tooltipRef = ref}>
  <button>I'm a button</button>
</ReactSuperTooltip>

<button onClick={() => { this.tooltipRef.hide() }}>Hide tooltip</button>

License

MIT

0.4.2

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.3.0

3 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.0.5

4 years ago

0.0.6

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago