Skip to content

Commit e5df642

Browse files
Merge branch 'master' of github.com:ReactTooltip/react-tooltip
2 parents 125dbb0 + cd7f5ba commit e5df642

File tree

8 files changed

+32
-10
lines changed

8 files changed

+32
-10
lines changed

docs/docs/options.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,5 @@ import { Tooltip } from 'react-tooltip';
123123
| `middlewares` | `Middleware[]` | no | | array of valid `floating-ui` middlewares | Allows for advanced customization. Check the [`floating-ui` docs](https://floating-ui.com/docs/middleware) for more information |
124124
| `border` | `CSSProperties['border']` | no | | a CSS border style | Change the style of the tooltip border (including the arrow) |
125125
| `opacity` | `CSSProperties['opacity']` | no | `0.9` | a CSS opacity value | Change the opacity of the tooltip |
126+
| `arrowColor` | `CSSProperties['backgroundColor']` | no | | a CSS background color | Change color of the tooltip arrow |
126127
| `disableStyleInjection` | <code>`boolean` &#124; `'core'`</code> | no | `false` | `true` `false` `'core'` | Whether to disable automatic style injection. Do not set dynamically. Check the [styling page](./examples/styling#disabling-reacttooltip-css) for more details |

docs/docs/upgrade-guide/changelog-v4-v5.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ If you run into any problems with the tooltip not updating after changes are mad
6868
- [ ] `textColor` - use `className` and custom CSS
6969
- [ ] `backgroundColor` - use `className` and custom CSS
7070
- [ ] `borderColor` - use `border` prop
71-
- [ ] `arrowColor` - use `className` and custom CSS
71+
- [x] `arrowColor`
7272
- [ ] `arrowRadius` - use `className` and custom CSS
7373
- [ ] `tooltipRadius` - use `className` and custom CSS
7474
- [ ] `insecure`

src/components/Tooltip/Tooltip.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const Tooltip = ({
4747
setActiveAnchor,
4848
border,
4949
opacity,
50+
arrowColor,
5051
}: ITooltip) => {
5152
const tooltipRef = useRef<HTMLElement>(null)
5253
const tooltipArrowRef = useRef<HTMLElement>(null)
@@ -654,7 +655,12 @@ const Tooltip = ({
654655
[coreStyles['noArrow']]: noArrow,
655656
},
656657
)}
657-
style={inlineArrowStyles}
658+
style={{
659+
...inlineArrowStyles,
660+
background: arrowColor
661+
? `linear-gradient(to right bottom, transparent 50%, ${arrowColor} 50%)`
662+
: undefined,
663+
}}
658664
ref={tooltipArrowRef}
659665
/>
660666
</WrapperElement>

src/components/Tooltip/TooltipTypes.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,5 @@ export interface ITooltip {
9191
setActiveAnchor: (anchor: HTMLElement | null) => void
9292
border?: CSSProperties['border']
9393
opacity?: CSSProperties['opacity']
94+
arrowColor?: CSSProperties['backgroundColor']
9495
}

src/components/Tooltip/styles.module.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,24 @@
88
.arrow {
99
width: 8px;
1010
height: 8px;
11+
}
12+
13+
[class*='react-tooltip__place-top'] > .arrow {
1114
transform: rotate(45deg);
1215
}
1316

17+
[class*='react-tooltip__place-right'] > .arrow {
18+
transform: rotate(135deg);
19+
}
20+
21+
[class*='react-tooltip__place-bottom'] > .arrow {
22+
transform: rotate(225deg);
23+
}
24+
25+
[class*='react-tooltip__place-left'] > .arrow {
26+
transform: rotate(315deg);
27+
}
28+
1429
/** Types variant **/
1530
.dark {
1631
background: var(--rt-color-dark);

src/components/TooltipController/TooltipController.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const TooltipController = ({
4747
disableStyleInjection = false,
4848
border,
4949
opacity,
50+
arrowColor,
5051
setIsOpen,
5152
afterShow,
5253
afterHide,
@@ -334,6 +335,7 @@ const TooltipController = ({
334335
isOpen,
335336
border,
336337
opacity,
338+
arrowColor,
337339
setIsOpen,
338340
afterShow,
339341
afterHide,

src/components/TooltipController/TooltipControllerTypes.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export interface ITooltipController {
6969
*/
7070
border?: CSSProperties['border']
7171
opacity?: CSSProperties['opacity']
72+
arrowColor?: CSSProperties['backgroundColor']
7273
setIsOpen?: (value: boolean) => void
7374
afterShow?: () => void
7475
afterHide?: () => void

src/utils/compute-positions.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,10 @@ export const computeTooltipPosition = async ({
4444
left: 'right',
4545
}[placement.split('-')[0]] ?? 'bottom'
4646

47-
const borderSide =
48-
border &&
49-
{
50-
top: { borderBottom: border, borderRight: border },
51-
right: { borderBottom: border, borderLeft: border },
52-
bottom: { borderTop: border, borderLeft: border },
53-
left: { borderTop: border, borderRight: border },
54-
}[placement.split('-')[0]]
47+
const borderSide = border && {
48+
borderBottom: border,
49+
borderRight: border,
50+
}
5551

5652
let borderWidth = 0
5753
if (border) {

0 commit comments

Comments
 (0)