0.0.1 • Published 7 months ago

react-single-tooltip v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

react-single-tooltip is a opinionated tooltip component. It uses no dependencies. so, it is tiny yet intelligent.

Usage

To start using the library, install it in your project:

npm install react-single-tooltip
# pnpm i react-single-tooltip
# yarn i react-single-tooltip

# canary
# or npm i react-single-tooltip@canary
# or pnpm i react-single-tooltip@canary
# or yarn i react-single-tooltip@canary

Add <SingleTooltip /> to your app, it will be the place where all your tooltip will be rendered. After that you can use useTooltip() hook in your component.

import SingleTooltip, { useTooltip } from 'react-single-tooltip';
import { useRef } from 'react'

// ...

function App() {
  const ref = useRef(null)
  useTooltip(ref, "Tooltip content")
  
  return (
    <div>
      <SingleTooltip />
      <button ref={ref}>Hover me</button>
    </div>
  );
}

Props

SingleTooltip component

NameTypeDefaultDescription
backgroundColorstringrgba(0, 0, 0, 0.8)-
zIndexnumber99-
borderRadiusnumber12-
offsetnumber | string4container padding

useTooltip params

You can dynamically show/hide the tooltip.

useTooltip(ref: React.RefObject<HTMLElement | SVGSVGElement>, text: string, show = true)
0.0.2-canary.2

7 months ago

0.0.2-canary.1

8 months ago

0.0.2-canary.0

8 months ago

0.0.1

8 months ago

0.0.1-canary.6

8 months ago

0.0.1-canary.5

8 months ago

0.0.1-canary.4

8 months ago

0.0.1-canary.3

8 months ago

0.0.1-canary.2

8 months ago

0.0.1-canary.1

8 months ago

0.0.1-canary.0

9 months ago