Skip to content

Commit 3a96888

Browse files
docs: disableStyleInjection tooltip prop
1 parent b62fa2f commit 3a96888

File tree

2 files changed

+48
-77
lines changed

2 files changed

+48
-77
lines changed

docs/docs/examples/styling.mdx

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,14 @@ import { Tooltip } from 'react-tooltip'
106106
Please note that **Core** styles are different from **Base** styles, for more information, please check the [Disabling ReactTooltip CSS](#disabling-reacttooltip-css) section.
107107
:::
108108

109+
##### Base styles
110+
109111
In this example, we are adding an extra level to the CSS classes. The following are the default **base** styles for the tooltip:
110112

111113
<CodeBlock language="css">{TooltipStyles}</CodeBlock>
112114

115+
##### Core styles
116+
113117
And the following are the **core** styles for the tooltip:
114118

115119
<CodeBlock language="css">{TooltipCoreStyles}</CodeBlock>
@@ -370,45 +374,22 @@ In summary, if you do it correctly you can use CSS specificity instead of `!impo
370374

371375
### Disabling ReactTooltip CSS
372376

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:
385379

386-
:::
387-
388-
| name | type | required | default | values | description |
389-
| ----------------------------------- | --------- | -------- | ------- | -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
390-
| `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.
392382

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.
394384

395385
:::caution
396386

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.
398388

399389
:::
400390

401-
The function `removeStyle` accepts the following params:
402-
403-
| name | type | required | default | values | description |
404-
| ---- | ------ | -------- | ------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
405-
| 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
409392

410-
...
393+
Check out more details about the [base](#base-styles) and [core](#core-styles) styles.
411394

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
414-
```
395+
:::

0 commit comments

Comments
 (0)