Skip to content

Commit 65cb02d

Browse files
docs: mention the opacity CSS variable
1 parent 2c2e027 commit 65cb02d

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

docs/docs/examples/styling.mdx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ import { Tooltip } from 'react-tooltip'
256256

257257
### Changing the opacity
258258

259-
Overriding the opacity through CSS breaks the tooltip. Use the `opacity` prop instead.
259+
Setting the opacity through CSS directly on the tooltip element breaks functionality. Use the `opacity` prop, or override the `--rt-opacity` CSS variable instead.
260260

261261
```jsx
262262
import { Tooltip } from 'react-tooltip'
@@ -269,6 +269,13 @@ import { Tooltip } from 'react-tooltip'
269269
</div>
270270
```
271271

272+
```css
273+
/* To be used instead of the `opacity` prop, not required otherwise */
274+
:root {
275+
--rt-opacity: 0.3;
276+
}
277+
```
278+
272279
<div
273280
className="example-container"
274281
style={{ display: 'flex', columnGap: '16px', justifyContent: 'center' }}

docs/docs/troubleshooting.mdx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,20 @@ If `data-tooltip-content` and `data-tooltip-html` are both unset (or they have e
6868

6969
This usually happens when you try to set the tooltip opacity via CSS. Due to the opacity being used internally to control the tooltip state, overriding it breaks functionality.
7070

71-
Instead, use [the `opacity` prop](./examples/styling#changing-the-opacity).
71+
Instead, use the `opacity` prop, or override the `--rt-opacity` CSS variable. See [the examples](./examples/styling#changing-the-opacity) for more details.
7272

7373
```jsx
7474
<Tooltip opacity={1} />
7575
```
7676

77+
or
78+
79+
```css
80+
:root {
81+
--rt-opacity: 1;
82+
}
83+
```
84+
7785
## The border doesn't show for the arrow
7886

7987
Simply setting the border for the tooltip through CSS will not work for the arrow.

0 commit comments

Comments
 (0)