Skip to content
This repository was archived by the owner on Mar 1, 2024. It is now read-only.

Commit 046fb35

Browse files
committed
feat(Tooltip): Add placement-based arrow positioning (centering)
The arrow will now always point towards the reference element while being centered with the tooltip (no matter the size or number of lines)
1 parent 85c24ea commit 046fb35

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/components/Tooltip/Tooltip.react.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ class Tooltip extends React.Component<Props, State> {
4242
className
4343
);
4444

45-
const arrowClasses = cn("arrow", styles["tbr-arrow"]);
45+
const arrowClasses = cn(
46+
"arrow",
47+
placement === "top" || placement === "bottom"
48+
? styles["tbr-arrow-vertical"]
49+
: styles["tbr-arrow-horizontal"]
50+
);
4651

4752
return (
4853
<Manager>

src/components/Tooltip/tooltip.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
/* Tooltip-specific Stylesheet */
22

3-
.tbr-arrow {
3+
.tbr-arrow-vertical {
44
left: calc(50% - 0.4rem);
55
}
6+
7+
.tbr-arrow-horizontal {
8+
top: calc(50% - 0.4rem);
9+
}

0 commit comments

Comments
 (0)