Anchor select
Using the ReactTooltip anchor select prop.
Basic usage
The anchorSelect prop uses a CSS selector to attach the tooltip to the anchor elements. The most common use for this is selecting elements with a specific id, or with a CSS class.
Using id attribute
A CSS selector for a specific id begins with a #. Don't forget to put it before the id on your selector!
import { Tooltip } from 'react-tooltip';
<a id="my-anchor-element-id">◕‿‿◕</a>
<Tooltip
// Don't forget the `#`!
anchorSelect="#my-anchor-element-id"
content="Hello world!"
/>
Using class attribute
A CSS selector for a specific class begins with a .. Don't forget to put it before the class on your selector!
import { Tooltip } from 'react-tooltip';
<a className="my-anchor-element-class">◕‿‿◕</a>
<a className="my-anchor-element-class">◕‿‿◕</a>
<a className="my-anchor-element-class">◕‿‿◕</a>
<a className="my-anchor-element-class">◕‿‿◕</a>
<Tooltip
// Don't forget the `.`!
anchorSelect=".my-anchor-element-class"
content="Hello world!"
/>
Complex selectors
Once you've understood how it works, you can write CSS selectors as complex as you can imagine. Here are some interesting examples.
Attribute prefix
[attr^='prefix'] can be read as "any element that has an attribute attr in which its value starts with prefix". Remove the ^ for an exact match.
This example uses the name attribute, but it works for any HTML attribute (id, class, ...).
import { Tooltip } from 'react-tooltip';
<a name="my-anchor-element-1">◕‿‿◕</a>
<a name="my-anchor-element-2">