react-tooltip 4.5.1 → 5.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +25 -0
- package/.eslintrc.json +94 -0
- package/.gitattributes +3 -0
- package/.github/FUNDING.yml +13 -0
- package/.github/workflows/lint.yaml +35 -0
- package/.github/workflows/pull-request.yaml +11 -0
- package/.github/workflows/release.yaml +30 -0
- package/.husky/pre-commit +6 -0
- package/.prettierrc.json +10 -0
- package/.stylelintrc.json +19 -0
- package/.vscode/settings.json +27 -0
- package/bower.json +26 -0
- package/build/dist/react-tooltip.cjs.js +2909 -0
- package/build/dist/react-tooltip.cjs.min.js +6 -0
- package/build/dist/react-tooltip.css +73 -0
- package/build/dist/react-tooltip.esm.js +2901 -0
- package/build/dist/react-tooltip.esm.min.js +6 -0
- package/build/dist/react-tooltip.min.css +1 -0
- package/build/dist/react-tooltip.umd.js +2913 -0
- package/build/dist/react-tooltip.umd.min.js +6 -0
- package/build/index.css +79 -0
- package/build/index.html +19 -0
- package/build/index.js +36190 -0
- package/cli.js +30 -0
- package/contributing.md +40 -0
- package/dist/react-tooltip-tokens.css +8 -0
- package/dist/react-tooltip.cjs.js +2932 -0
- package/dist/react-tooltip.cjs.min.js +6 -0
- package/dist/react-tooltip.css +73 -0
- package/dist/react-tooltip.d.ts +21 -120
- package/dist/react-tooltip.esm.js +2924 -0
- package/dist/react-tooltip.esm.min.js +6 -0
- package/dist/react-tooltip.min.css +1 -0
- package/dist/react-tooltip.umd.js +2936 -0
- package/dist/react-tooltip.umd.min.js +6 -0
- package/docs/README.md +50 -0
- package/docs/babel.config.js +3 -0
- package/docs/docs/examples/_category_.json +7 -0
- package/docs/docs/examples/basic-examples.mdx +68 -0
- package/docs/docs/examples/children.mdx +67 -0
- package/docs/docs/examples/content.mdx +80 -0
- package/docs/docs/examples/delay.mdx +84 -0
- package/docs/docs/examples/events.mdx +85 -0
- package/docs/docs/examples/get-content.mdx +58 -0
- package/docs/docs/examples/html.mdx +75 -0
- package/docs/docs/examples/multiline.mdx +91 -0
- package/docs/docs/examples/offset.mdx +69 -0
- package/docs/docs/examples/place.mdx +55 -0
- package/docs/docs/examples/state.mdx +331 -0
- package/docs/docs/examples/styling.mdx +388 -0
- package/docs/docs/examples/variant.mdx +100 -0
- package/docs/docs/getting-started.mdx +100 -0
- package/docs/docs/options.mdx +105 -0
- package/docs/docs/upgrade-guide/_category_.json +7 -0
- package/docs/docs/upgrade-guide/basic-examples-v4-v5.mdx +119 -0
- package/docs/docs/upgrade-guide/changelog-v4-v5.md +86 -0
- package/docs/docusaurus.config.js +135 -0
- package/docs/package.json +47 -0
- package/docs/sidebars.js +33 -0
- package/docs/src/components/HomepageFeatures/index.tsx +71 -0
- package/docs/src/components/HomepageFeatures/styles.module.css +11 -0
- package/docs/src/css/custom.css +74 -0
- package/docs/src/pages/index.module.css +35 -0
- package/docs/src/pages/index.tsx +45 -0
- package/docs/src/pages/markdown-page.md +7 -0
- package/docs/static/.nojekyll +0 -0
- package/docs/static/img/Octocat.jpg +0 -0
- package/docs/static/img/Octocat.png +0 -0
- package/docs/static/img/Octocat.svg +9 -0
- package/docs/static/img/android-chrome-192x192.png +0 -0
- package/docs/static/img/android-chrome-512x512.png +0 -0
- package/docs/static/img/apple-touch-icon.png +0 -0
- package/docs/static/img/docusaurus.png +0 -0
- package/docs/static/img/favicon-16x16.png +0 -0
- package/docs/static/img/favicon-32x32.png +0 -0
- package/docs/static/img/favicon-old.ico +0 -0
- package/docs/static/img/favicon.ico +0 -0
- package/docs/static/img/github.svg +1 -0
- package/docs/static/img/happy-face-tooltip.png +0 -0
- package/docs/static/img/happy-face-tooltip.svg +21 -0
- package/docs/static/img/logo-dinossaur.svg +1 -0
- package/docs/static/img/logo.png +0 -0
- package/docs/static/img/logo.svg +21 -0
- package/docs/static/img/only-tooltip-top.png +0 -0
- package/docs/static/img/only-tooltip-top.svg +4 -0
- package/docs/static/img/only-tooltip.png +0 -0
- package/docs/static/img/only-tooltip.svg +4 -0
- package/docs/static/img/site.webmanifest +1 -0
- package/docs/static/img/undraw_docusaurus_mountain.svg +171 -0
- package/docs/static/img/undraw_docusaurus_react.svg +170 -0
- package/docs/static/img/undraw_docusaurus_tree.svg +40 -0
- package/docs/tsconfig.json +7 -0
- package/docs/yarn.lock +7599 -0
- package/example-v5/package.json +21 -0
- package/example-v5/public/index.html +20 -0
- package/example-v5/public/manifest.json +8 -0
- package/example-v5/src/App.jsx +908 -0
- package/example-v5/src/index.css +238 -0
- package/example-v5/src/index.js +15 -0
- package/example-v5/src/index.scss +251 -0
- package/package.json +94 -146
- package/public/index.html +19 -0
- package/rollup.config.dev.js +88 -0
- package/rollup.config.prod.js +104 -0
- package/rollup.config.types.js +17 -0
- package/tsconfig.json +109 -0
- package/dist/index.es.js +0 -3185
- package/dist/index.es.js.map +0 -1
- package/dist/index.js +0 -3192
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 1
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Styling
|
|
6
|
+
|
|
7
|
+
How to customize tooltip styles in ReactTooltip styles.
|
|
8
|
+
|
|
9
|
+
import { Tooltip } from 'react-tooltip'
|
|
10
|
+
import 'react-tooltip/dist/react-tooltip.css'
|
|
11
|
+
|
|
12
|
+
export const TooltipAnchor = ({ children, id, ...rest }) => {
|
|
13
|
+
return (
|
|
14
|
+
<span
|
|
15
|
+
id={id}
|
|
16
|
+
style={{
|
|
17
|
+
display: 'flex',
|
|
18
|
+
justifyContent: 'center',
|
|
19
|
+
alignItems: 'center',
|
|
20
|
+
width: '60px',
|
|
21
|
+
height: '60px',
|
|
22
|
+
borderRadius: '60px',
|
|
23
|
+
color: '#222',
|
|
24
|
+
background: 'rgba(255, 255, 255, 1)',
|
|
25
|
+
cursor: 'pointer',
|
|
26
|
+
boxShadow: '3px 4px 3px rgba(0, 0, 0, 0.5)',
|
|
27
|
+
border: '1px solid #333',
|
|
28
|
+
}}
|
|
29
|
+
{...rest}
|
|
30
|
+
>
|
|
31
|
+
{children}
|
|
32
|
+
</span>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
### Basic explanation
|
|
37
|
+
|
|
38
|
+
You don't need `!important` anymore, you just need to know at least a bit about CSS Specificity ([MDN Docs](https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity) | [W3c Docs](https://www.w3schools.com/css/css_specificity.asp)).
|
|
39
|
+
Using CSS Specificity you can add a class with more specificity than the current used in tooltip and you can override or add new rules to the component style.
|
|
40
|
+
|
|
41
|
+
```jsx
|
|
42
|
+
import { Tooltip } from 'react-tooltip'
|
|
43
|
+
import 'react-tooltip/dist/react-tooltip.css'
|
|
44
|
+
|
|
45
|
+
<style>
|
|
46
|
+
.example-container .example {
|
|
47
|
+
color: #222;
|
|
48
|
+
background-color: rgb(0, 247, 255);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.example-container .example .example-arrow {
|
|
52
|
+
background-color: rgb(0, 247, 255);
|
|
53
|
+
}
|
|
54
|
+
</style>
|
|
55
|
+
|
|
56
|
+
<div className="example-container">
|
|
57
|
+
<a id="custom-styles" data-tooltip-content="hello world!">
|
|
58
|
+
◕‿‿◕
|
|
59
|
+
</a>
|
|
60
|
+
<Tooltip anchorId="custom-styles" className="example" classNameArrow="example-arrow" />
|
|
61
|
+
</div>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
<div
|
|
65
|
+
className="example-container"
|
|
66
|
+
style={{ display: 'flex', columnGap: '16px', justifyContent: 'center' }}
|
|
67
|
+
>
|
|
68
|
+
<TooltipAnchor id="custom-styles" data-tooltip-content="hello world!">
|
|
69
|
+
◕‿‿◕
|
|
70
|
+
</TooltipAnchor>
|
|
71
|
+
<Tooltip anchorId="custom-styles" className="example" classNameArrow="example-arrow" />
|
|
72
|
+
</div>
|
|
73
|
+
|
|
74
|
+
#### Explanation
|
|
75
|
+
|
|
76
|
+
In this example, we are adding an extra level to the CSS classes, the following styles are the default one of Tooltip component when we write this docs:
|
|
77
|
+
|
|
78
|
+
```css
|
|
79
|
+
.tooltip {
|
|
80
|
+
visibility: hidden;
|
|
81
|
+
width: max-content;
|
|
82
|
+
position: absolute;
|
|
83
|
+
top: 0;
|
|
84
|
+
left: 0;
|
|
85
|
+
padding: 8px 16px;
|
|
86
|
+
border-radius: 3px;
|
|
87
|
+
font-size: 90%;
|
|
88
|
+
pointer-events: none;
|
|
89
|
+
opacity: 0;
|
|
90
|
+
transition: opacity 0.3s ease-out;
|
|
91
|
+
will-change: opacity, visibility;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.arrow {
|
|
95
|
+
position: absolute;
|
|
96
|
+
background: var(--rt-color-dark);
|
|
97
|
+
width: 8px;
|
|
98
|
+
height: 8px;
|
|
99
|
+
transform: rotate(45deg);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** Types variant **/
|
|
103
|
+
.dark,
|
|
104
|
+
.dark .arrow {
|
|
105
|
+
background: var(--rt-color-dark);
|
|
106
|
+
color: var(--rt-color-white);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.light,
|
|
110
|
+
.light .arrow {
|
|
111
|
+
background-color: var(--rt-color-white);
|
|
112
|
+
color: var(--rt-color-dark);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.success,
|
|
116
|
+
.success .arrow {
|
|
117
|
+
background-color: var(--rt-color-success);
|
|
118
|
+
color: var(--rt-color-white);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.warning,
|
|
122
|
+
.warning .arrow {
|
|
123
|
+
background-color: var(--rt-color-warning);
|
|
124
|
+
color: var(--rt-color-white);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.error,
|
|
128
|
+
.error .arrow {
|
|
129
|
+
background-color: var(--rt-color-error);
|
|
130
|
+
color: var(--rt-color-white);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.info,
|
|
134
|
+
.info .arrow {
|
|
135
|
+
background-color: var(--rt-color-info);
|
|
136
|
+
color: var(--rt-color-white);
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
So, if we only add new classes like the below, this will not work because this is the same level of specificity than the default dark variant as example, you can compare:
|
|
141
|
+
|
|
142
|
+
```css
|
|
143
|
+
.example {
|
|
144
|
+
color: #222;
|
|
145
|
+
background-color: rgb(0, 247, 255);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.example .example-arrow {
|
|
149
|
+
background-color: rgb(0, 247, 255);
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
```css
|
|
154
|
+
.tooltip {
|
|
155
|
+
...;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.dark,
|
|
159
|
+
.dark .arrow {
|
|
160
|
+
background: var(--rt-color-dark);
|
|
161
|
+
color: var(--rt-color-white);
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
So, to make this work as expected, we need to add a new more level like this one:
|
|
166
|
+
|
|
167
|
+
```css
|
|
168
|
+
.some-class-or-rule .example {
|
|
169
|
+
color: #222;
|
|
170
|
+
background-color: rgb(0, 247, 255);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.some-class-or-rule .example .example-arrow {
|
|
174
|
+
background-color: rgb(0, 247, 255);
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Now this will work as expected.
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
### More examples - Colors
|
|
183
|
+
|
|
184
|
+
#### Orange
|
|
185
|
+
|
|
186
|
+
```jsx
|
|
187
|
+
import { Tooltip } from 'react-tooltip'
|
|
188
|
+
import 'react-tooltip/dist/react-tooltip.css'
|
|
189
|
+
|
|
190
|
+
<style>
|
|
191
|
+
.example-container .example-orange {
|
|
192
|
+
color: #222;
|
|
193
|
+
background-color: rgb(255, 153, 0);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.example-container .example-orange .example-arrow {
|
|
197
|
+
background-color: rgb(255, 153, 0);
|
|
198
|
+
}
|
|
199
|
+
</style>
|
|
200
|
+
|
|
201
|
+
<div className="example-container">
|
|
202
|
+
<a id="custom-styles-orange" data-tooltip-content="hello world!">
|
|
203
|
+
◕‿‿◕
|
|
204
|
+
</a>
|
|
205
|
+
<Tooltip anchorId="custom-styles-orange" className="example-orange" classNameArrow="example-arrow" />
|
|
206
|
+
</div>
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
<div
|
|
210
|
+
className="example-container"
|
|
211
|
+
style={{ display: 'flex', columnGap: '16px', justifyContent: 'center' }}
|
|
212
|
+
>
|
|
213
|
+
<TooltipAnchor id="custom-styles-orange" data-tooltip-content="hello world!">
|
|
214
|
+
◕‿‿◕
|
|
215
|
+
</TooltipAnchor>
|
|
216
|
+
<Tooltip
|
|
217
|
+
anchorId="custom-styles-orange"
|
|
218
|
+
className="example-orange"
|
|
219
|
+
classNameArrow="example-arrow"
|
|
220
|
+
/>
|
|
221
|
+
</div>
|
|
222
|
+
|
|
223
|
+
#### Pink
|
|
224
|
+
|
|
225
|
+
```jsx
|
|
226
|
+
import { Tooltip } from 'react-tooltip'
|
|
227
|
+
import 'react-tooltip/dist/react-tooltip.css'
|
|
228
|
+
|
|
229
|
+
<style>
|
|
230
|
+
.example-container .example-pink {
|
|
231
|
+
color: #fff;
|
|
232
|
+
background-color: rgb(255, 0, 255);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.example-container .example-pink .example-arrow {
|
|
236
|
+
background-color: rgb(255, 0, 255);
|
|
237
|
+
}
|
|
238
|
+
</style>
|
|
239
|
+
|
|
240
|
+
<div className="example-container">
|
|
241
|
+
<a id="custom-styles-pink" data-tooltip-content="hello world!">
|
|
242
|
+
◕‿‿◕
|
|
243
|
+
</a>
|
|
244
|
+
<Tooltip anchorId="custom-styles-pink" className="example-pink" classNameArrow="example-arrow" />
|
|
245
|
+
</div>
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
<div
|
|
249
|
+
className="example-container"
|
|
250
|
+
style={{ display: 'flex', columnGap: '16px', justifyContent: 'center' }}
|
|
251
|
+
>
|
|
252
|
+
<TooltipAnchor id="custom-styles-pink" data-tooltip-content="hello world!">
|
|
253
|
+
◕‿‿◕
|
|
254
|
+
</TooltipAnchor>
|
|
255
|
+
<Tooltip anchorId="custom-styles-pink" className="example-pink" classNameArrow="example-arrow" />
|
|
256
|
+
</div>
|
|
257
|
+
|
|
258
|
+
### More examples - Radius
|
|
259
|
+
|
|
260
|
+
#### Removing radius
|
|
261
|
+
|
|
262
|
+
```jsx
|
|
263
|
+
import { Tooltip } from 'react-tooltip'
|
|
264
|
+
import 'react-tooltip/dist/react-tooltip.css'
|
|
265
|
+
|
|
266
|
+
<style>
|
|
267
|
+
.example-container .example-no-radius {
|
|
268
|
+
border-radius: 0;
|
|
269
|
+
}
|
|
270
|
+
</style>
|
|
271
|
+
|
|
272
|
+
<div className="example-container">
|
|
273
|
+
<a id="custom-styles-no-radius" data-tooltip-content="hello world!">
|
|
274
|
+
◕‿‿◕
|
|
275
|
+
</a>
|
|
276
|
+
<Tooltip anchorId="custom-styles-no-radius" className="example-no-radius" />
|
|
277
|
+
</div>
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
<div
|
|
281
|
+
className="example-container"
|
|
282
|
+
style={{ display: 'flex', columnGap: '16px', justifyContent: 'center' }}
|
|
283
|
+
>
|
|
284
|
+
<TooltipAnchor id="custom-styles-no-radius" data-tooltip-content="hello world!">
|
|
285
|
+
◕‿‿◕
|
|
286
|
+
</TooltipAnchor>
|
|
287
|
+
<Tooltip anchorId="custom-styles-no-radius" className="example-no-radius" />
|
|
288
|
+
</div>
|
|
289
|
+
|
|
290
|
+
#### Rounded
|
|
291
|
+
|
|
292
|
+
```jsx
|
|
293
|
+
import { Tooltip } from 'react-tooltip'
|
|
294
|
+
import 'react-tooltip/dist/react-tooltip.css'
|
|
295
|
+
|
|
296
|
+
<style>
|
|
297
|
+
.example-container .example-rounded {
|
|
298
|
+
border-radius: 50%;
|
|
299
|
+
}
|
|
300
|
+
</style>
|
|
301
|
+
|
|
302
|
+
<div className="example-container">
|
|
303
|
+
<a id="custom-styles-rounded" data-tooltip-content="hello world!">
|
|
304
|
+
◕‿‿◕
|
|
305
|
+
</a>
|
|
306
|
+
<Tooltip anchorId="custom-styles-rounded" className="example-rounded" />
|
|
307
|
+
</div>
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
<div
|
|
311
|
+
className="example-container"
|
|
312
|
+
style={{ display: 'flex', columnGap: '16px', justifyContent: 'center' }}
|
|
313
|
+
>
|
|
314
|
+
<TooltipAnchor id="custom-styles-rounded" data-tooltip-content="hello world!">
|
|
315
|
+
◕‿‿◕
|
|
316
|
+
</TooltipAnchor>
|
|
317
|
+
<Tooltip anchorId="custom-styles-rounded" className="example-rounded" />
|
|
318
|
+
</div>
|
|
319
|
+
|
|
320
|
+
### More examples - Padding
|
|
321
|
+
|
|
322
|
+
#### Removing padding
|
|
323
|
+
|
|
324
|
+
```jsx
|
|
325
|
+
import { Tooltip } from 'react-tooltip'
|
|
326
|
+
import 'react-tooltip/dist/react-tooltip.css'
|
|
327
|
+
|
|
328
|
+
<style>
|
|
329
|
+
.example-container .example-no-padding {
|
|
330
|
+
padding: 0;
|
|
331
|
+
}
|
|
332
|
+
</style>
|
|
333
|
+
|
|
334
|
+
<div className="example-container">
|
|
335
|
+
<a id="custom-styles-no-padding" data-tooltip-content="hello world!">
|
|
336
|
+
◕‿‿◕
|
|
337
|
+
</a>
|
|
338
|
+
<Tooltip anchorId="custom-styles-no-padding" className="example-no-padding" />
|
|
339
|
+
</div>
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
<div
|
|
343
|
+
className="example-container"
|
|
344
|
+
style={{ display: 'flex', columnGap: '16px', justifyContent: 'center' }}
|
|
345
|
+
>
|
|
346
|
+
<TooltipAnchor id="custom-styles-no-padding" data-tooltip-content="hello world!">
|
|
347
|
+
◕‿‿◕
|
|
348
|
+
</TooltipAnchor>
|
|
349
|
+
<Tooltip anchorId="custom-styles-no-padding" className="example-no-padding" />
|
|
350
|
+
</div>
|
|
351
|
+
|
|
352
|
+
#### Adding more padding
|
|
353
|
+
|
|
354
|
+
```jsx
|
|
355
|
+
import { Tooltip } from 'react-tooltip'
|
|
356
|
+
import 'react-tooltip/dist/react-tooltip.css'
|
|
357
|
+
|
|
358
|
+
<style>
|
|
359
|
+
.example-container .example-padding {
|
|
360
|
+
border-radius: 50%;
|
|
361
|
+
}
|
|
362
|
+
</style>
|
|
363
|
+
|
|
364
|
+
<div className="example-container">
|
|
365
|
+
<a id="custom-styles-padding" data-tooltip-content="hello world!">
|
|
366
|
+
◕‿‿◕
|
|
367
|
+
</a>
|
|
368
|
+
<Tooltip anchorId="custom-styles-padding" className="example-padding" />
|
|
369
|
+
</div>
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
<div
|
|
373
|
+
className="example-container"
|
|
374
|
+
style={{ display: 'flex', columnGap: '16px', justifyContent: 'center' }}
|
|
375
|
+
>
|
|
376
|
+
<TooltipAnchor id="custom-styles-padding" data-tooltip-content="hello world!">
|
|
377
|
+
◕‿‿◕
|
|
378
|
+
</TooltipAnchor>
|
|
379
|
+
<Tooltip anchorId="custom-styles-padding" className="example-padding" />
|
|
380
|
+
</div>
|
|
381
|
+
|
|
382
|
+
#### Observation
|
|
383
|
+
|
|
384
|
+
This doc is only if you are importing `import 'react-tooltip/dist/react-tooltip.css'`, if not, you can write your classes by you directly.
|
|
385
|
+
|
|
386
|
+
With CSS specificity everything can be overridden if you know what are you doing.
|
|
387
|
+
|
|
388
|
+
The necessity of `!import` was removed because `!import` cut a lot of levels/possibilities related to CSS specificity.
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 1
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Variant
|
|
6
|
+
|
|
7
|
+
Standard colors available in ReactTooltip styles.
|
|
8
|
+
|
|
9
|
+
import { Tooltip } from 'react-tooltip'
|
|
10
|
+
import 'react-tooltip/dist/react-tooltip.css'
|
|
11
|
+
|
|
12
|
+
export const TooltipAnchor = ({ children, id, ...rest }) => {
|
|
13
|
+
return (
|
|
14
|
+
<span
|
|
15
|
+
id={id}
|
|
16
|
+
style={{
|
|
17
|
+
display: 'flex',
|
|
18
|
+
justifyContent: 'center',
|
|
19
|
+
alignItems: 'center',
|
|
20
|
+
width: '60px',
|
|
21
|
+
height: '60px',
|
|
22
|
+
borderRadius: '60px',
|
|
23
|
+
color: '#222',
|
|
24
|
+
background: 'rgba(255, 255, 255, 1)',
|
|
25
|
+
cursor: 'pointer',
|
|
26
|
+
boxShadow: '3px 4px 3px rgba(0, 0, 0, 0.5)',
|
|
27
|
+
border: '1px solid #333',
|
|
28
|
+
}}
|
|
29
|
+
{...rest}
|
|
30
|
+
>
|
|
31
|
+
{children}
|
|
32
|
+
</span>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
`variant` available values `dark` | `light` | `success` | `warning` | `error` | `info`
|
|
37
|
+
|
|
38
|
+
```jsx
|
|
39
|
+
import { Tooltip } from 'react-tooltip';
|
|
40
|
+
import 'react-tooltip/dist/react-tooltip.css';
|
|
41
|
+
|
|
42
|
+
<a
|
|
43
|
+
id="attributes-variant"
|
|
44
|
+
data-tooltip-content="hello world!"
|
|
45
|
+
data-tooltip-variant="success"
|
|
46
|
+
> ◕‿‿◕ </a>
|
|
47
|
+
|
|
48
|
+
<Tooltip anchorId="attributes-variant" />
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
<div style={{ display: 'flex', columnGap: '16px', justifyContent: 'center' }}>
|
|
52
|
+
<TooltipAnchor
|
|
53
|
+
id="attributes-variant-success"
|
|
54
|
+
data-tooltip-content="success tooltip color"
|
|
55
|
+
data-tooltip-variant="success"
|
|
56
|
+
>
|
|
57
|
+
◕‿‿◕
|
|
58
|
+
</TooltipAnchor>
|
|
59
|
+
<Tooltip anchorId="attributes-variant-success" />
|
|
60
|
+
<TooltipAnchor
|
|
61
|
+
id="attributes-variant-error"
|
|
62
|
+
data-tooltip-content="error tooltip color"
|
|
63
|
+
data-tooltip-variant="error"
|
|
64
|
+
>
|
|
65
|
+
◕‿‿◕
|
|
66
|
+
</TooltipAnchor>
|
|
67
|
+
<Tooltip anchorId="attributes-variant-error" />
|
|
68
|
+
<TooltipAnchor
|
|
69
|
+
id="attributes-variant-warning"
|
|
70
|
+
data-tooltip-content="warning tooltip color"
|
|
71
|
+
data-tooltip-variant="warning"
|
|
72
|
+
>
|
|
73
|
+
◕‿‿◕
|
|
74
|
+
</TooltipAnchor>
|
|
75
|
+
<Tooltip anchorId="attributes-variant-warning" />
|
|
76
|
+
<Tooltip anchorId="attributes-variant-info" />
|
|
77
|
+
<TooltipAnchor
|
|
78
|
+
id="attributes-variant-info"
|
|
79
|
+
data-tooltip-content="info tooltip color"
|
|
80
|
+
data-tooltip-variant="info"
|
|
81
|
+
>
|
|
82
|
+
◕‿‿◕
|
|
83
|
+
</TooltipAnchor>
|
|
84
|
+
<Tooltip anchorId="attributes-variant-dark" />
|
|
85
|
+
<TooltipAnchor
|
|
86
|
+
id="attributes-variant-dark"
|
|
87
|
+
data-tooltip-content="dark tooltip color"
|
|
88
|
+
data-tooltip-variant="dark"
|
|
89
|
+
>
|
|
90
|
+
◕‿‿◕
|
|
91
|
+
</TooltipAnchor>
|
|
92
|
+
<Tooltip anchorId="attributes-variant-light" />
|
|
93
|
+
<TooltipAnchor
|
|
94
|
+
id="attributes-variant-light"
|
|
95
|
+
data-tooltip-content="light tooltip color"
|
|
96
|
+
data-tooltip-variant="light"
|
|
97
|
+
>
|
|
98
|
+
◕‿‿◕
|
|
99
|
+
</TooltipAnchor>
|
|
100
|
+
</div>
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 1
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Getting Started
|
|
6
|
+
|
|
7
|
+
This docs is related to V5, [if you are using V4 please check here](https://reacttooltip.github.io/react-tooltip/)
|
|
8
|
+
|
|
9
|
+
A react tooltip is a floating react element that displays information related to an anchor element when it receives keyboard focus or the mouse hovers over it.
|
|
10
|
+
|
|
11
|
+
import { Tooltip } from 'react-tooltip'
|
|
12
|
+
import 'react-tooltip/dist/react-tooltip.css'
|
|
13
|
+
|
|
14
|
+
export const TooltipAnchor = ({ children, id, ...rest }) => {
|
|
15
|
+
return (
|
|
16
|
+
<span
|
|
17
|
+
id={id}
|
|
18
|
+
style={{
|
|
19
|
+
display: 'flex',
|
|
20
|
+
justifyContent: 'center',
|
|
21
|
+
alignItems: 'center',
|
|
22
|
+
width: '60px',
|
|
23
|
+
height: '60px',
|
|
24
|
+
borderRadius: '60px',
|
|
25
|
+
color: '#222',
|
|
26
|
+
background: 'rgba(255, 255, 255, 1)',
|
|
27
|
+
cursor: 'pointer',
|
|
28
|
+
boxShadow: '3px 4px 3px rgba(0, 0, 0, 0.5)',
|
|
29
|
+
border: '1px solid #333',
|
|
30
|
+
}}
|
|
31
|
+
{...rest}
|
|
32
|
+
>
|
|
33
|
+
{children}
|
|
34
|
+
</span>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm install react-tooltip@5.0.0-beta.0
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
or
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
yarn add react-tooltip@5.0.0-beta.0
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Usage
|
|
51
|
+
|
|
52
|
+
There are two ways to use ReactTooltip.
|
|
53
|
+
|
|
54
|
+
1. Using props into ReactTooltip Element.
|
|
55
|
+
2. Using data-attributes on anchor element.
|
|
56
|
+
|
|
57
|
+
### ReactTooltip props
|
|
58
|
+
|
|
59
|
+
1 . Require react-tooltip after installation
|
|
60
|
+
|
|
61
|
+
```js
|
|
62
|
+
import ReactTooltip from 'react-tooltip'
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
2 . Add data-content = "your placeholder" to your element
|
|
66
|
+
|
|
67
|
+
```jsx
|
|
68
|
+
<p id="my-anchor-element">Tooltip</p>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
3 . Include react-tooltip component
|
|
72
|
+
|
|
73
|
+
```jsx
|
|
74
|
+
<ReactTooltip anchorId="my-anchor-element" content="hello world" place="top" />
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Anchor data attributes
|
|
78
|
+
|
|
79
|
+
1 . Require react-tooltip after installation
|
|
80
|
+
|
|
81
|
+
```js
|
|
82
|
+
import ReactTooltip from 'react-tooltip'
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
2 . Add data-content = "your placeholder" to your element
|
|
86
|
+
|
|
87
|
+
```jsx
|
|
88
|
+
<p id="my-anchor-element" data-content="hello world" data-place="top">
|
|
89
|
+
Tooltip
|
|
90
|
+
</p>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
3 . Include react-tooltip component
|
|
94
|
+
|
|
95
|
+
```jsx
|
|
96
|
+
<ReactTooltip anchorId="my-anchor-element" />
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
<TooltipAnchor id="props-basic">◕‿‿◕</TooltipAnchor>
|
|
100
|
+
<Tooltip anchorId="props-basic" content="hello world!" />
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 3
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Options
|
|
6
|
+
|
|
7
|
+
All available prop and data-attribute options of ReactTooltip.
|
|
8
|
+
|
|
9
|
+
import { Tooltip } from 'react-tooltip'
|
|
10
|
+
import 'react-tooltip/dist/react-tooltip.css'
|
|
11
|
+
|
|
12
|
+
export const TooltipAnchor = ({ children, id, ...rest }) => {
|
|
13
|
+
return (
|
|
14
|
+
<span
|
|
15
|
+
id={id}
|
|
16
|
+
style={{
|
|
17
|
+
display: 'flex',
|
|
18
|
+
justifyContent: 'center',
|
|
19
|
+
alignItems: 'center',
|
|
20
|
+
width: '60px',
|
|
21
|
+
height: '60px',
|
|
22
|
+
borderRadius: '60px',
|
|
23
|
+
color: '#222',
|
|
24
|
+
background: 'rgba(255, 255, 255, 1)',
|
|
25
|
+
cursor: 'pointer',
|
|
26
|
+
boxShadow: '3px 4px 3px rgba(0, 0, 0, 0.5)',
|
|
27
|
+
border: '1px solid #333',
|
|
28
|
+
}}
|
|
29
|
+
{...rest}
|
|
30
|
+
>
|
|
31
|
+
{children}
|
|
32
|
+
</span>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
### Props
|
|
37
|
+
|
|
38
|
+
```jsx
|
|
39
|
+
import { Tooltip } from 'react-tooltip';
|
|
40
|
+
import 'react-tooltip/dist/react-tooltip.css'
|
|
41
|
+
|
|
42
|
+
<a id="props-basic"> ◕‿‿◕ </a>
|
|
43
|
+
|
|
44
|
+
<Tooltip anchorId="props-basic" content="hello world!" />
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
<TooltipAnchor id="props-basic">◕‿‿◕</TooltipAnchor>
|
|
48
|
+
<Tooltip anchorId="props-basic" content="hello world!" />
|
|
49
|
+
|
|
50
|
+
#### Available props
|
|
51
|
+
|
|
52
|
+
| name | type | required | default | values | description |
|
|
53
|
+
| -------------- | -------------------- | -------- | ------------------------- | ------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
54
|
+
| className | string | false | | | class name to customize tooltip element |
|
|
55
|
+
| classNameArrow | string | false | | | class name to customize tooltip arrow element |
|
|
56
|
+
| content | string | false | | | content to de displayed in tooltip (`content` prop is priorized over `html`) |
|
|
57
|
+
| html | string | false | | | html content to de displayed in tooltip |
|
|
58
|
+
| place | string | false | `top` | `top` `right` `bottom` `left` | place related to anchor element where the tooltip will be rendered if possible |
|
|
59
|
+
| offset | number | false | `10` | any `number` | space between the tooltip element and anchor element (arrow not included in calc) |
|
|
60
|
+
| id | string | false | React `useId` | any `string` | option to set a specific id into the tooltip element, the default value is handled by React `useId` introduced on React 18 |
|
|
61
|
+
| anchorId | string | false | `undefined` | any `string` | id reference from the element that the tooltip will be positioned around |
|
|
62
|
+
| variant | string | false | `dark` | `dark` `light` `success` `warning` `error` `info` | change the colors of tooltip with pre-defined values |
|
|
63
|
+
| wrapper | valid element | false | `div` | `ElementType` `div` `span` | element wrapper of tooltip container, can be `div`, `span` or any valid Element |
|
|
64
|
+
| children | valid React children | false | `undefined` | valid React children | content can be pass through props, data-attributes or as children, children will be priorized over other options |
|
|
65
|
+
| events | array | false | `hover` | `hover` `click` | pre-defined events to handle show or hide tooltip |
|
|
66
|
+
| delayShow | number | false | | any `number` | tooltip show will be delayed in miliseconds by the amount of value |
|
|
67
|
+
| delayHide | number | false | | any `number` | tooltip hide will be delayed in miliseconds by the amount of value |
|
|
68
|
+
| getContent | function | false | | (value: string) => string | a method available to parse, format or modify the given content of tooltip before show it |
|
|
69
|
+
| isOpen | boolen | false | handled by internal state | `true` `false` | the tooltip can be controlled or uncontrolled, this attribute can be used to handle show and hide tooltip outside tooltip (can be used **without** `setIsOpen`) |
|
|
70
|
+
| setIsOpen | function | false | | | the tooltip can be controlled or uncontrolled, this attribute can be used to handle show and hide tooltip outside tooltip |
|
|
71
|
+
|
|
72
|
+
### Data attributes
|
|
73
|
+
|
|
74
|
+
```jsx
|
|
75
|
+
import { Tooltip } from 'react-tooltip';
|
|
76
|
+
import 'react-tooltip/dist/react-tooltip.css';
|
|
77
|
+
|
|
78
|
+
<a id="attributes-basic" data-content="hello world!"> ◕‿‿◕ </a>
|
|
79
|
+
|
|
80
|
+
<Tooltip anchorId="attributes-basic" />
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
<TooltipAnchor id="attributes-basic" data-content="hello world!">
|
|
84
|
+
◕‿‿◕
|
|
85
|
+
</TooltipAnchor>
|
|
86
|
+
<Tooltip anchorId="attributes-basic" />
|
|
87
|
+
|
|
88
|
+
#### Available attributes
|
|
89
|
+
|
|
90
|
+
| name | type | required | default | values | description |
|
|
91
|
+
| -------------------- | ------ | -------- | ------- | ------------------------------------------------- | --------------------------------------------------------------------------------- |
|
|
92
|
+
| data-tooltip-content | string | false | | | content to de displayed in tooltip (`content` prop is priorized over `html`) |
|
|
93
|
+
| data-tooltip-html | string | false | | | html content to de displayed in tooltip |
|
|
94
|
+
| data-tooltip-place | string | false | `top` | `top` `right` `bottom` `left` | place related to anchor element where the tooltip will be rendered if possible |
|
|
95
|
+
| data-tooltip-offset | number | false | `10` | any `number` | space between the tooltip element and anchor element (arrow not included in calc) |
|
|
96
|
+
| data-tooltip-variant | string | false | `dark` | `dark` `light` `success` `warning` `error` `info` | change the colors of tooltip with pre-defined values |
|
|
97
|
+
| data-tooltip-wrapper | string | false | `div` | `div` `span` | element wrapper of tooltip container, can be `div`, `span` or any valid Element |
|
|
98
|
+
| data-tooltip-events | string | false | `hover` | `hover click` `hover` `click` | pre-defined events to handle show or hide tooltip |
|
|
99
|
+
| data-tooltip-show | number | false | | any `number` | tooltip show will be delayed in miliseconds by the amount of value |
|
|
100
|
+
| data-tooltip-hide | number | false | | any `number` | tooltip hide will be delayed in miliseconds by the amount of value |
|
|
101
|
+
|
|
102
|
+
#### Observations
|
|
103
|
+
|
|
104
|
+
- When using `data-tooltip-content` the `<br />` works by default
|
|
105
|
+
- When using prop `content` the `<br />` doesn't work by default, use prop `html` instead of this
|