You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> Don't forget to set the id, it won't work without it!
84
+
85
+
```jsx
86
+
<Tooltip id="my-tooltip"/>
77
87
```
78
88
79
-
4 . Include react-tooltip component
89
+
#### Using multiple anchor elements
90
+
91
+
You can also set the `anchorSelect` tooltip prop to use the tooltip with multiple anchor elements without having to set `data-tooltip-id` on each of them.
92
+
`anchorSelect` must be a valid [CSS selector](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors).
<a className="my-anchor-element" data-tooltip-content="Hello to you too!">
99
+
◕‿‿◕
100
+
</a>
101
+
<Tooltip anchorSelect=".my-anchor-element"/>
83
102
```
84
103
104
+
Check [the V5 docs](https://react-tooltip.com/docs/getting-started) for more complex use cases.
105
+
85
106
### Standalone
86
107
87
108
You can import `node_modules/react-tooltip/dist/react-tooltip.[mode].js` into your page. Please make sure that you have already imported `react` and `react-dom` into your page.
@@ -98,27 +119,26 @@ PS: all the files have a minified version and a non-minified version.
98
119
99
120
For all available options, please check [React Tooltip Options](https://react-tooltip.com/docs/options)
100
121
101
-
### Security Note
122
+
### Security note
102
123
103
124
The `html` option allows a tooltip to directly display raw HTML. This is a security risk if any of that content is supplied by the user. Any user-supplied content must be sanitized, using a package like [sanitize-html](https://www.npmjs.com/package/sanitize-html). We chose not to include sanitization after discovering it [increased our package size](https://github.com/wwayne/react-tooltip/issues/429) too much - we don't want to penalize people who don't use the `html` option.
104
125
105
-
#### JSX Note
126
+
#### JSX note
106
127
107
-
You can use React's [`renderToStaticMarkup`-function](https://reactjs.org/docs/react-dom-server.html#rendertostaticmarkup) to use JSX instead of HTML.
128
+
You can use [`React.renderToStaticMarkup()`function](https://reactjs.org/docs/react-dom-server.html#rendertostaticmarkup) to use JSX instead of HTML.
108
129
**Example:**
109
130
110
131
```jsx
111
132
importReactDOMServerfrom'react-dom/server';
112
133
[...]
113
-
<p id="my-element" data-tooltip-html={ReactDOMServer.renderToString(<div>I am <b>JSX</b> content</div>)}>
114
-
Hover me
115
-
</p>
134
+
<a
135
+
data-tooltip-id="my-tooltip"
136
+
data-tooltip-html={ReactDOMServer.renderToStaticMarkup(<div>I am <b>JSX</b> content</div>)}
137
+
>
138
+
◕‿‿◕
139
+
</a>
116
140
```
117
141
118
-
#### Note
119
-
120
-
-**id** is necessary, because `<ReactTooltip anchorId="my-element" />` finds the tooltip via this attribute
121
-
122
142
## Article
123
143
124
144
[How I insert sass into react component](https://medium.com/@wwayne_me/how-i-insert-sass-into-my-npm-react-component-b46b9811c226#.gi4hxu44a)
0 commit comments