0.1.20 • Published 11 months ago

@deepdub/react-ok-tooltip v0.1.20

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

React Ok Tooltip

React Ok Tooltip is a simple and easy to use tooltip component for React.

Usage

Inside App.tsx:

import { OkTooltip } from '@deepdub/react-ok-tooltip';
import '@deepdub/react-ok-tooltip/dist/tooltip.css';

function App() {
  return (
    <>
      {/* insert app here... */}
      <OkTooltip arrowSize={5} />
    </>
  );
}

Then, inside Component.tsx:

import { tooltip } from '@deepdub/react-ok-tooltip';

function Component() {
  return (
    <button ref={tooltip('I am a tooltip!')}>Hover me!</button>
  );
}

Options

Tooltip Options

tooltip() method accepts two parameters: title (a string) and options (an object of shape TooltipProps).

TooltipProps may include any of the follwing:

  • subtitle: string - A subtitle that will appear, well, below the title.
  • maxWidth: string - A string, passed to the tooltip's style.maxWidth.
  • fontWeight: string - A string, passed to the tooltip's style.fontWeight.

All are optional.

Global Tooltip Options

Customize the tooltip by passing any of these to <Tooltip>:

  • arrowSize: number - The size of the arrow.
  • backgroundColor: string - The background color of the tooltip.
  • borderColor: string - The border color of the tooltip.
  • delay: number - Tooltip delay in milliseconds (default: 1000).
  • className: string - Will be passed on the to tooltip itself.
  • arrowClassName: string - Will be passed on the to tooltip itself.

All are optional.

Tooltip Group

React Ok Tooltip also supports a concept we've called "tooltip group".

A tooltip group lets you anchor multiple tooltips to a single element (as shown in the GIF above, when the cursor hovers the middle section).

Usage

import { tooltip } from '@deepdub/react-ok-tooltip';

function Component() {
  return (
    <div ref={tooltipGroup()}>
      <button ref={tooltip('Cut Selection')}>Cut</button>
      <button ref={tooltip('Copy Selection')}>Copy</button>
      <button ref={tooltip('Paste')}>Paste</button>
    </div>
  );
}
0.1.20

11 months ago

0.1.18

1 year ago

0.1.19

1 year ago

0.1.16

2 years ago

0.1.17

2 years ago

0.1.14

2 years ago

0.1.15

2 years ago

0.1.11

2 years ago

0.1.12

2 years ago

0.1.13

2 years ago

0.1.10

2 years ago

0.1.9

2 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.5-0

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago