react-tooltip 5.0.0-beta.1 → 5.0.0-beta.2

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.
Files changed (125) hide show
  1. package/.eslintrc.json +2 -1
  2. package/CODE_OF_CONDUCT.md +53 -0
  3. package/LICENSE +1 -2
  4. package/README.md +30 -152
  5. package/coverage/clover.xml +610 -0
  6. package/coverage/coverage-final.json +11 -0
  7. package/coverage/lcov-report/base.css +224 -0
  8. package/coverage/lcov-report/block-navigation.js +87 -0
  9. package/coverage/lcov-report/components/Tooltip/Tooltip.tsx.html +646 -0
  10. package/coverage/lcov-report/components/Tooltip/index.html +146 -0
  11. package/coverage/lcov-report/components/Tooltip/index.ts.html +88 -0
  12. package/coverage/lcov-report/components/Tooltip/styles.module.css.html +277 -0
  13. package/coverage/lcov-report/components/TooltipContent/TooltipContent.tsx.html +109 -0
  14. package/coverage/lcov-report/components/TooltipContent/index.html +131 -0
  15. package/coverage/lcov-report/components/TooltipContent/index.ts.html +88 -0
  16. package/coverage/lcov-report/components/TooltipController/TooltipController.tsx.html +664 -0
  17. package/coverage/lcov-report/components/TooltipController/constants.ts.html +118 -0
  18. package/coverage/lcov-report/components/TooltipController/index.html +146 -0
  19. package/coverage/lcov-report/components/TooltipController/index.ts.html +88 -0
  20. package/coverage/lcov-report/favicon.png +0 -0
  21. package/coverage/lcov-report/index.html +161 -0
  22. package/coverage/lcov-report/prettify.css +1 -0
  23. package/coverage/lcov-report/prettify.js +2 -0
  24. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  25. package/coverage/lcov-report/sorter.js +196 -0
  26. package/coverage/lcov-report/sum.js.html +97 -0
  27. package/coverage/lcov-report/sum.ts.html +100 -0
  28. package/coverage/lcov-report/test/index.html +116 -0
  29. package/coverage/lcov-report/test/sum.ts.html +100 -0
  30. package/coverage/lcov-report/utils/compute-positions.ts.html +277 -0
  31. package/coverage/lcov-report/utils/debounce.ts.html +181 -0
  32. package/coverage/lcov-report/utils/index.html +131 -0
  33. package/coverage/lcov.info +729 -0
  34. package/dist/react-tooltip.cjs.js +3 -6
  35. package/dist/react-tooltip.cjs.min.js +1 -1
  36. package/dist/react-tooltip.esm.js +3 -6
  37. package/dist/react-tooltip.esm.min.js +1 -1
  38. package/dist/react-tooltip.umd.js +3 -6
  39. package/dist/react-tooltip.umd.min.js +1 -1
  40. package/jest.config.ts +214 -0
  41. package/package.json +12 -4
  42. package/tsconfig.json +2 -2
  43. package/.github/FUNDING.yml +0 -13
  44. package/.github/workflows/lint.yaml +0 -35
  45. package/.github/workflows/pull-request.yaml +0 -11
  46. package/.github/workflows/release.yaml +0 -30
  47. package/.husky/pre-commit +0 -6
  48. package/.vscode/settings.json +0 -27
  49. package/build/dist/react-tooltip.cjs.js +0 -2909
  50. package/build/dist/react-tooltip.cjs.min.js +0 -6
  51. package/build/dist/react-tooltip.css +0 -73
  52. package/build/dist/react-tooltip.esm.js +0 -2901
  53. package/build/dist/react-tooltip.esm.min.js +0 -6
  54. package/build/dist/react-tooltip.min.css +0 -1
  55. package/build/dist/react-tooltip.umd.js +0 -2913
  56. package/build/dist/react-tooltip.umd.min.js +0 -6
  57. package/build/index.css +0 -79
  58. package/build/index.html +0 -19
  59. package/build/index.js +0 -36190
  60. package/docs/README.md +0 -50
  61. package/docs/babel.config.js +0 -3
  62. package/docs/docs/examples/_category_.json +0 -7
  63. package/docs/docs/examples/basic-examples.mdx +0 -68
  64. package/docs/docs/examples/children.mdx +0 -67
  65. package/docs/docs/examples/content.mdx +0 -80
  66. package/docs/docs/examples/delay.mdx +0 -84
  67. package/docs/docs/examples/events.mdx +0 -85
  68. package/docs/docs/examples/get-content.mdx +0 -58
  69. package/docs/docs/examples/html.mdx +0 -75
  70. package/docs/docs/examples/multiline.mdx +0 -91
  71. package/docs/docs/examples/offset.mdx +0 -69
  72. package/docs/docs/examples/place.mdx +0 -55
  73. package/docs/docs/examples/state.mdx +0 -331
  74. package/docs/docs/examples/styling.mdx +0 -388
  75. package/docs/docs/examples/variant.mdx +0 -100
  76. package/docs/docs/getting-started.mdx +0 -100
  77. package/docs/docs/options.mdx +0 -105
  78. package/docs/docs/upgrade-guide/_category_.json +0 -7
  79. package/docs/docs/upgrade-guide/basic-examples-v4-v5.mdx +0 -119
  80. package/docs/docs/upgrade-guide/changelog-v4-v5.md +0 -86
  81. package/docs/docusaurus.config.js +0 -135
  82. package/docs/package.json +0 -47
  83. package/docs/sidebars.js +0 -33
  84. package/docs/src/components/HomepageFeatures/index.tsx +0 -71
  85. package/docs/src/components/HomepageFeatures/styles.module.css +0 -11
  86. package/docs/src/css/custom.css +0 -74
  87. package/docs/src/pages/index.module.css +0 -35
  88. package/docs/src/pages/index.tsx +0 -45
  89. package/docs/src/pages/markdown-page.md +0 -7
  90. package/docs/static/.nojekyll +0 -0
  91. package/docs/static/img/Octocat.jpg +0 -0
  92. package/docs/static/img/Octocat.png +0 -0
  93. package/docs/static/img/Octocat.svg +0 -9
  94. package/docs/static/img/android-chrome-192x192.png +0 -0
  95. package/docs/static/img/android-chrome-512x512.png +0 -0
  96. package/docs/static/img/apple-touch-icon.png +0 -0
  97. package/docs/static/img/docusaurus.png +0 -0
  98. package/docs/static/img/favicon-16x16.png +0 -0
  99. package/docs/static/img/favicon-32x32.png +0 -0
  100. package/docs/static/img/favicon-old.ico +0 -0
  101. package/docs/static/img/favicon.ico +0 -0
  102. package/docs/static/img/github.svg +0 -1
  103. package/docs/static/img/happy-face-tooltip.png +0 -0
  104. package/docs/static/img/happy-face-tooltip.svg +0 -21
  105. package/docs/static/img/logo-dinossaur.svg +0 -1
  106. package/docs/static/img/logo.png +0 -0
  107. package/docs/static/img/logo.svg +0 -21
  108. package/docs/static/img/only-tooltip-top.png +0 -0
  109. package/docs/static/img/only-tooltip-top.svg +0 -4
  110. package/docs/static/img/only-tooltip.png +0 -0
  111. package/docs/static/img/only-tooltip.svg +0 -4
  112. package/docs/static/img/site.webmanifest +0 -1
  113. package/docs/static/img/undraw_docusaurus_mountain.svg +0 -171
  114. package/docs/static/img/undraw_docusaurus_react.svg +0 -170
  115. package/docs/static/img/undraw_docusaurus_tree.svg +0 -40
  116. package/docs/tsconfig.json +0 -7
  117. package/docs/yarn.lock +0 -7599
  118. package/example-v5/package.json +0 -21
  119. package/example-v5/public/index.html +0 -20
  120. package/example-v5/public/manifest.json +0 -8
  121. package/example-v5/src/App.jsx +0 -908
  122. package/example-v5/src/index.css +0 -238
  123. package/example-v5/src/index.js +0 -15
  124. package/example-v5/src/index.scss +0 -251
  125. package/public/index.html +0 -19
@@ -1,388 +0,0 @@
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.
@@ -1,100 +0,0 @@
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>
@@ -1,100 +0,0 @@
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!" />
@@ -1,105 +0,0 @@
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
@@ -1,7 +0,0 @@
1
- {
2
- "label": "Upgrade Guide",
3
- "position": 2,
4
- "link": {
5
- "type": "generated-index"
6
- }
7
- }