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
Copy file name to clipboardExpand all lines: docs/docs/examples/styling.mdx
+13-32Lines changed: 13 additions & 32 deletions
Original file line number
Diff line number
Diff line change
@@ -106,10 +106,14 @@ import { Tooltip } from 'react-tooltip'
106
106
Please note that **Core** styles are different from **Base** styles, for more information, please check the [Disabling ReactTooltip CSS](#disabling-reacttooltip-css) section.
107
107
:::
108
108
109
+
##### Base styles
110
+
109
111
In this example, we are adding an extra level to the CSS classes. The following are the default **base** styles for the tooltip:
@@ -370,45 +374,22 @@ In summary, if you do it correctly you can use CSS specificity instead of `!impo
370
374
371
375
### Disabling ReactTooltip CSS
372
376
373
-
There are two ways to remove the ReactTooltip CSS:
374
-
375
-
#### Environment Variables
376
-
377
-
You can prevent ReactTooltip from injecting styles into the page by using environment variables, we currently support two types of styles: `core styles` and `base styles`.
378
-
379
-
- Core Styles: basic styles that are necessary to make the tooltip work.
380
-
- Base Styles: visual styles to make the tooltip pretty.
381
-
382
-
:::info
383
-
384
-
We strongly recommend using this way because it's cleaner and better for performance to choose not to inject the styles instead of injecting and removing them when the page loads.
377
+
ReactTooltip works seamlessly by automatically injects CSS into your application. To disable this functionality, use the tooltip prop `disableStyleInjection`.
378
+
Details on how it works:
385
379
386
-
:::
387
-
388
-
| name | type | required | default | values | description |
|`REACT_TOOLTIP_DISABLE_CORE_STYLES`|`boolean`| no |`false`|`true``false`| Environment variable to disable **core** styles from being injected into the page by ReactTooltip.<br /><br /> We strongly recommend to keep the core styles being injected into the project unless you know what you are doing. |
391
-
|`REACT_TOOLTIP_DISABLE_BASE_STYLES`|`boolean`| no |`false`|`true``false`| Environment variable to disable **base** styles from being injected into the page by ReactTooltip.<br /><br /> Those styles are just visual styles like colors, padding, etc... And can be disabled if you want to write your tooltip styles. |
380
+
- Set to `true`: what we call "base" styles will be disabled. Useful if you wish to style your tooltip from scratch.
381
+
- Set to `'core'`: both the "base" and the "core" styles will be disabled. This means the tooltip will not work properly without adding specific CSS attributes to it.
392
382
393
-
#### Using removeStyle function
383
+
In both cases, you can add `import 'react-tooltip/dist/react-tooltip.css'` to your project to get the tooltip working again, or add your own custom CSS.
394
384
395
385
:::caution
396
386
397
-
Only use this method if you really can't use the environment variables to disable the style injection of ReactTooltip because this can impact the page performance.
387
+
Do not set `disableStyleInjection` dynamically. Changing its value requires a page refresh, so that will not work.
398
388
399
389
:::
400
390
401
-
The function `removeStyle` accepts the following params:
402
-
403
-
| name | type | required | default | values | description |
| type | string | no |`base`|`base``core`| If `core` is defined, the core styles will be removed from the page, if nothing is defined, `base` styles will be removed as default value |
406
-
407
-
```jsx
408
-
import { removeStyle } from'react-tooltip'
391
+
:::info
409
392
410
-
...
393
+
Check out more details about the [base](#base-styles) and [core](#core-styles) styles.
411
394
412
-
removeStyle() // removes the injected base style of ReactTooltip
413
-
removeStyle({ type:'core' }) // removes the injected core style of ReactTooltip - this can affect the basic functionality of ReactTooltip
0 commit comments