2.0.3 • Published 6 years ago

react-accessible-tooltip v2.0.3

Weekly downloads
197
License
-
Repository
github
Last release
6 years ago

React Accessible Tooltip · GitHub license NPM release CircleCI Status Code coverage

Try out the interactive demo here.

React Accessible Tooltip is a component which lets you build accessible tooltips. It handles all the interactivity and accessibility stuff, but keeps out of the way so you can use whatever markup and styling you want.

Basic usage requires you to pass 'label' and 'overlay' render functions. React Accessible Tooltip passes you both the state of the tooltip (isHidden) and an object full of properties you should spread across your components (labelAttributes, overlayAttributes).

Getting started

Installation

Install this package and it's co-dependencies:

npm install react-accessible-tooltip react react-dom

Basic Usage

import { Tooltip } from "react-accessible-tooltip";
<Tooltip
    label={props => (
        <span {...props.labelAttributes} className="tooltip-label">
            {`hover me for info`}
        </span>
    )}
    overlay={props => (
        <span
            {...props.overlayAttributes}
            className={
                props.isHidden
                    ? "tooltip-overlay tooltip-overlay--hidden"
                    : "tooltip-overlay"
            }
        >
            {`this is more info`}
        </span>
    )}
/>;

Props

label : function({ isHidden, labelAttributes, requestHide, requestShow, requestToggle }) => React.Node

The label prop should be passed a render function. The function will be called with these arguments:

PropertyTypeDescription
isHiddenbooleanThe current state of the tooltip.
labelAttributesobjectThe various attributes which ought to be assigned to the outer-most element in your render function (eg. <span {...labelAttributes} />).
requestHidefunctionCallable which manually sets the state of the tooltip to 'hidden'.
requestShowfunctionCallable which manually sets the state of the tooltip to 'shown'.
requestTogglefunctionCallable which manually toggles the state of the tooltip between 'shown' or 'hidden'.

overlay : function({ isHidden, overlayAttributes, requestHide, requestShow, requestToggle }) => React.Node

The overlay prop should be passed a render function. The function will be called with these arguments:

PropertyTypeDescription
isHiddenbooleanThe current state of the tooltip.
overlayAttributesobjectThe various attributes which ought to be assigned to the outer-most element in your render function (eg. <span {...overlayAttributes} />).
requestHidefunctionCallable which manually sets the state of the tooltip to 'hidden'.
requestShowfunctionCallable which manually sets the state of the tooltip to 'shown'.
requestTogglefunctionCallable which manually toggles the state of the tooltip between 'shown' or 'hidden'.

License

MIT.

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.5.6

6 years ago

1.5.5

6 years ago

1.5.4

6 years ago

1.5.3

6 years ago

1.5.2

6 years ago

1.5.2-rc10

6 years ago

1.5.2-rc8

6 years ago

1.5.2-rc7

6 years ago

1.5.2-rc2

6 years ago

1.5.1

6 years ago

1.5.0

6 years ago

1.4.1

6 years ago

1.4.0

6 years ago

1.3.2

6 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.16

7 years ago

1.2.15

7 years ago

1.2.14

7 years ago

1.2.13

7 years ago

1.2.12

7 years ago

1.2.11

7 years ago

1.2.10

7 years ago

1.2.8

7 years ago

1.2.7

7 years ago

1.2.6

7 years ago

1.2.5

7 years ago

1.2.4

7 years ago

1.2.3

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago