1.0.9 • Published 5 years ago

react-float-tooltip v1.0.9

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

react-float-tooltip

NPM JavaScript Style Guide semantic-release Coverage Status Build Status

Preview

This React Component lets you create full-controlled float tooltips like that. And it's easy to use 👍. Also check out demo page 😉

react-float-tooltip gif

Getting started

Install with npm or yarn

npm install --save react-float-tooltip

or

yarn add react-float-tooltip

This uses portals so you need to add id="tooltip-root" to your index.html next to id="root"

<div id="root"></div>
<!-- tooltip container -->
<div id="tooltip-root"></div>

react-float-tooltip adds a Tooltip wrapper that takes tooltip component as a tooltipElement prop.

import React, { Component } from 'react'
import Tooltip from 'react-float-tooltip'

class App extends Component {
  render() {
    return (
      <div>
        <Tooltip tooltipElement={() => <div style={{background: 'yellow'}}>Tooltip</div>}>
          <div>Element with tooltip</div>
        </Tooltip>
      </div>
    );
  }
}

export default App;

Check example folder for more.

Api

Props

nametypedefaultisRequireddescription
disablebooleanfalsefalsedisable tooltip
isRevertbooleanfalsefalserevert tooltip if it has no place from the right edge
offsetnumber0falsetooltip offset from right edge
tooltipElementfunctiontruefunction that returns component for render tooltip
childrenReact.Elementtruewrapped element
classNamestringfalseclassName for children wrapper component
styleObjectfalsestyle for children wrapper component

Development

First, run rollup to watch your src/ module and automatically recompile it into dist/ whenever you make changes.

npm start # runs rollup with watch flag 

The second part will be running the example/ create-react-app that's linked to the local version of your module.

cd example
npm start # runs create-react-app dev server 

Now, anytime you make a change to your library in src/ or to the example app's example/src, create-react-app will live-reload your local dev server so you can iterate on your component in real-time.

Check create-react-library documentation for development.

License

MIT © gornyyvladimir

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago