diff --git a/docs/docs/options.mdx b/docs/docs/options.mdx
index 4cf2e3e1..d91b7d5c 100644
--- a/docs/docs/options.mdx
+++ b/docs/docs/options.mdx
@@ -123,4 +123,5 @@ import { Tooltip } from 'react-tooltip';
| `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 |
| `border` | `CSSProperties['border']` | no | | a CSS border style | Change the style of the tooltip border (including the arrow) |
| `opacity` | `CSSProperties['opacity']` | no | `0.9` | a CSS opacity value | Change the opacity of the tooltip |
+| `arrowColor` | `CSSProperties['backgroundColor']` | no | | a CSS background color | Change color of the tooltip arrow |
| `disableStyleInjection` | `boolean` | `'core'`
| 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 |
diff --git a/docs/docs/upgrade-guide/changelog-v4-v5.md b/docs/docs/upgrade-guide/changelog-v4-v5.md
index a50f7574..a63a48f3 100644
--- a/docs/docs/upgrade-guide/changelog-v4-v5.md
+++ b/docs/docs/upgrade-guide/changelog-v4-v5.md
@@ -68,7 +68,7 @@ If you run into any problems with the tooltip not updating after changes are mad
- [ ] `textColor` - use `className` and custom CSS
- [ ] `backgroundColor` - use `className` and custom CSS
- [ ] `borderColor` - use `border` prop
-- [ ] `arrowColor` - use `className` and custom CSS
+- [x] `arrowColor`
- [ ] `arrowRadius` - use `className` and custom CSS
- [ ] `tooltipRadius` - use `className` and custom CSS
- [ ] `insecure`
diff --git a/src/components/Tooltip/Tooltip.tsx b/src/components/Tooltip/Tooltip.tsx
index bb2dec69..844f3ca2 100644
--- a/src/components/Tooltip/Tooltip.tsx
+++ b/src/components/Tooltip/Tooltip.tsx
@@ -47,6 +47,7 @@ const Tooltip = ({
setActiveAnchor,
border,
opacity,
+ arrowColor,
}: ITooltip) => {
const tooltipRef = useRef(null)
const tooltipArrowRef = useRef(null)
@@ -654,7 +655,12 @@ const Tooltip = ({
[coreStyles['noArrow']]: noArrow,
},
)}
- style={inlineArrowStyles}
+ style={{
+ ...inlineArrowStyles,
+ background: arrowColor
+ ? `linear-gradient(to right bottom, transparent 50%, ${arrowColor} 50%)`
+ : undefined,
+ }}
ref={tooltipArrowRef}
/>
diff --git a/src/components/Tooltip/TooltipTypes.d.ts b/src/components/Tooltip/TooltipTypes.d.ts
index 65a53c29..41760079 100644
--- a/src/components/Tooltip/TooltipTypes.d.ts
+++ b/src/components/Tooltip/TooltipTypes.d.ts
@@ -91,4 +91,5 @@ export interface ITooltip {
setActiveAnchor: (anchor: HTMLElement | null) => void
border?: CSSProperties['border']
opacity?: CSSProperties['opacity']
+ arrowColor?: CSSProperties['backgroundColor']
}
diff --git a/src/components/Tooltip/styles.module.css b/src/components/Tooltip/styles.module.css
index 6ab5e964..f14041e3 100644
--- a/src/components/Tooltip/styles.module.css
+++ b/src/components/Tooltip/styles.module.css
@@ -8,9 +8,24 @@
.arrow {
width: 8px;
height: 8px;
+}
+
+[class*='react-tooltip__place-top'] > .arrow {
transform: rotate(45deg);
}
+[class*='react-tooltip__place-right'] > .arrow {
+ transform: rotate(135deg);
+}
+
+[class*='react-tooltip__place-bottom'] > .arrow {
+ transform: rotate(225deg);
+}
+
+[class*='react-tooltip__place-left'] > .arrow {
+ transform: rotate(315deg);
+}
+
/** Types variant **/
.dark {
background: var(--rt-color-dark);
diff --git a/src/components/TooltipController/TooltipController.tsx b/src/components/TooltipController/TooltipController.tsx
index 424b5b11..729e77b8 100644
--- a/src/components/TooltipController/TooltipController.tsx
+++ b/src/components/TooltipController/TooltipController.tsx
@@ -47,6 +47,7 @@ const TooltipController = ({
disableStyleInjection = false,
border,
opacity,
+ arrowColor,
setIsOpen,
afterShow,
afterHide,
@@ -334,6 +335,7 @@ const TooltipController = ({
isOpen,
border,
opacity,
+ arrowColor,
setIsOpen,
afterShow,
afterHide,
diff --git a/src/components/TooltipController/TooltipControllerTypes.d.ts b/src/components/TooltipController/TooltipControllerTypes.d.ts
index 371b9e17..e0568907 100644
--- a/src/components/TooltipController/TooltipControllerTypes.d.ts
+++ b/src/components/TooltipController/TooltipControllerTypes.d.ts
@@ -69,6 +69,7 @@ export interface ITooltipController {
*/
border?: CSSProperties['border']
opacity?: CSSProperties['opacity']
+ arrowColor?: CSSProperties['backgroundColor']
setIsOpen?: (value: boolean) => void
afterShow?: () => void
afterHide?: () => void
diff --git a/src/utils/compute-positions.ts b/src/utils/compute-positions.ts
index 8e0048ae..efed5d7f 100644
--- a/src/utils/compute-positions.ts
+++ b/src/utils/compute-positions.ts
@@ -44,14 +44,10 @@ export const computeTooltipPosition = async ({
left: 'right',
}[placement.split('-')[0]] ?? 'bottom'
- const borderSide =
- border &&
- {
- top: { borderBottom: border, borderRight: border },
- right: { borderBottom: border, borderLeft: border },
- bottom: { borderTop: border, borderLeft: border },
- left: { borderTop: border, borderRight: border },
- }[placement.split('-')[0]]
+ const borderSide = border && {
+ borderBottom: border,
+ borderRight: border,
+ }
let borderWidth = 0
if (border) {