Skip to content

Commit 2c2e027

Browse files
docs: details on changing opacity/border
1 parent 41e2ae5 commit 2c2e027

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed

docs/docs/examples/styling.mdx

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,16 @@ import { Tooltip } from 'react-tooltip'
212212

213213
#### Tooltip Arrow with a different color from Tooltip
214214

215+
:::info
216+
217+
This is for demonstration purposes only. Using `arrowColor` instead is recommended.
218+
219+
```jsx
220+
<Tooltip arrowColor="red" />
221+
```
222+
223+
:::
224+
215225
```jsx
216226
import { Tooltip } from 'react-tooltip'
217227

@@ -244,6 +254,31 @@ import { Tooltip } from 'react-tooltip'
244254
<Tooltip id="my-tooltip-diff" className="example-diff-arrow" classNameArrow="example-arrow" />
245255
</div>
246256

257+
### Changing the opacity
258+
259+
Overriding the opacity through CSS breaks the tooltip. Use the `opacity` prop instead.
260+
261+
```jsx
262+
import { Tooltip } from 'react-tooltip'
263+
264+
<div className="example-container">
265+
<a data-tooltip-id="my-tooltip-opacity" data-tooltip-content="Hello world!">
266+
◕‿‿◕
267+
</a>
268+
<Tooltip id="my-tooltip-opacity" opacity={0.3} />
269+
</div>
270+
```
271+
272+
<div
273+
className="example-container"
274+
style={{ display: 'flex', columnGap: '16px', justifyContent: 'center' }}
275+
>
276+
<TooltipAnchor data-tooltip-id="my-tooltip-opacity" data-tooltip-content="Hello world!">
277+
◕‿‿◕
278+
</TooltipAnchor>
279+
<Tooltip id="my-tooltip-opacity" opacity={0.3} />
280+
</div>
281+
247282
### Changing the border radius
248283

249284
#### Removing radius
@@ -364,6 +399,33 @@ import { Tooltip } from 'react-tooltip'
364399
<Tooltip id="my-tooltip-padding" className="example-padding" />
365400
</div>
366401

402+
### Changing the border
403+
404+
If you're using the tooltip with the arrow, setting a border through CSS will not work for the arrow.
405+
406+
We recommend using the `border` prop to avoid that.
407+
408+
```jsx
409+
import { Tooltip } from 'react-tooltip'
410+
411+
<div className="example-container">
412+
<a data-tooltip-id="my-tooltip-border" data-tooltip-content="Hello world!">
413+
◕‿‿◕
414+
</a>
415+
<Tooltip id="my-tooltip-border" border="1px solid red" />
416+
</div>
417+
```
418+
419+
<div
420+
className="example-container"
421+
style={{ display: 'flex', columnGap: '16px', justifyContent: 'center' }}
422+
>
423+
<TooltipAnchor data-tooltip-id="my-tooltip-border" data-tooltip-content="Hello world!">
424+
◕‿‿◕
425+
</TooltipAnchor>
426+
<Tooltip id="my-tooltip-border" border="1px solid red" />
427+
</div>
428+
367429
---
368430

369431
:::info

docs/docs/troubleshooting.mdx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,26 @@ If you've imported the default styling and the tooltip is still not showing up w
6464

6565
If `data-tooltip-content` and `data-tooltip-html` are both unset (or they have empty values) on the anchor element, and also the `content`, `render`, and `children` props on the tooltip are unset (or have empty values), the tooltip is not shown by default.
6666

67+
## The tooltip doesn't close
68+
69+
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.
70+
71+
Instead, use [the `opacity` prop](./examples/styling#changing-the-opacity).
72+
73+
```jsx
74+
<Tooltip opacity={1} />
75+
```
76+
77+
## The border doesn't show for the arrow
78+
79+
Simply setting the border for the tooltip through CSS will not work for the arrow.
80+
81+
Instead, use [the `border` prop](./examples/styling#changing-the-border).
82+
83+
```jsx
84+
<Tooltip border="1px solid red" />
85+
```
86+
6787
## Bad performance
6888

6989
If you're experiencing any kind of unexpected behavior or bad performance on your application when using ReactTooltip, here are a few things you can try.

0 commit comments

Comments
 (0)