tooltips
An accessible tooltip component to help structure large amounts of content on a page.
The Tooltip component can be used in three forms:
- A standard hover tooltip over a link/button/text input;
- A hover tooltip over a non-focusable element (like a
<span>
, the JavaScript will make it accessible); - A togglable tooltip (click to hide/show).
There are also delay and timing options available, however the default timing of 1 second mimics the title attribute timing (which was the previous WCAG standard; timing requirements have since been removed).
Examples
Usage
* Standalone JS is used on projects that are not set up to handle ES6. To use this version you will need to download the UMD bundle from the NPM and pull it into your project. The same process should be followed with the CSS if it cannot process through the NPM package.
Documentation
Installation
This component accepts two arguments, the selector for the tooltip container and an optional callback function.
npm install @10up/component-tooltip --save
Methods
destroy() | Destroys the component, removing event listeners and any extra markup and attributes. |
---|
Classes
.a11y-tip | Wrapping class for the component. |
---|---|
.a11y-tip__trigger | Tooltip item trigger element. |
.a11y-tip__help | Tooltip content |
.a11y-tip--no-delay | Option to remove the delay |
.a11y-tip__help--top | Option to position the tooltip on top of the trigger. |
.a11y-tip__help--right | Option to position the tooltip on right of the trigger. |
.a11y-tip__help--left | Option to position the tooltip on left of the trigger. |
Browser Compatibility
Chrome | Latest |
---|---|
Firefox | Latest |
Edge | Latest |
Safari | Latest |
IE | 11 (Standalone only) |