Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(canvas): invert the chart tooltip against the page theme (#103866)

ruby childs9240a892279f
diff --git a/products/canvas/packages/canvas_builder/build.mjs b/products/canvas/packages/canvas_builder/build.mjs
index 69a10ab86bf6..347cd1a6d150 100644
--- a/products/canvas/packages/canvas_builder/build.mjs
+++ b/products/canvas/packages/canvas_builder/build.mjs
@@ -252,6 +252,29 @@ const platformStylesheet = `
.recharts-bar-rectangle path {
shape-rendering: crispEdges;
}
+
+/* Recharts colors each tooltip row with that row's series color over an inline white panel, so
+ the text fails contrast on any theme and is unreadable on a dark one. Inverting the panel
+ against the page is the highest contrast pair the theme defines, whatever the series colors
+ are, and it needs !important to beat the inline background. Each row keeps its inline series
+ color so the dot can read it through currentColor, while the text spans take the inverted
+ color. Everything else about the panel stays at the recharts default. */
+.recharts-default-tooltip {
+ background-color: var(--foreground) !important;
+}
+.recharts-tooltip-label,
+.recharts-tooltip-item > span {
+ color: var(--background);
+}
+.recharts-tooltip-item::before {
+ content: "";
+ display: inline-block;
+ width: 0.5rem;
+ height: 0.5rem;
+ margin-right: 0.375rem;
+ border-radius: 9999px;
+ background: currentColor;
+}
`
// Entry references (module scripts, stylesheets) parsed attribute-order-
diff --git a/products/canvas/skills/building-react-quill-canvases/SKILL.md b/products/canvas/skills/building-react-quill-canvases/SKILL.md
index c3d2706747ab..bd60df38026e 100644
--- a/products/canvas/skills/building-react-quill-canvases/SKILL.md
+++ b/products/canvas/skills/building-react-quill-canvases/SKILL.md
@@ -88,7 +88,9 @@ text-card-foreground`; borders `border-border`. Never a hardcoded hex or light-o
- Some recharts defaults are hardcoded for a light theme and go wrong on a dark canvas. The
platform stylesheet corrects them, so do not work around one in canvas code. Pie slice outlines
are one: recharts strokes every sector white, and the stylesheet removes the outline. The
- antialiasing seam between stacked bar segments is another.
+ antialiasing seam between stacked bar segments is another, and so is the default tooltip, which
+ the stylesheet inverts against the page so its text always meets contrast. A bare `<Tooltip />`
+ is the right thing to write.
- Write Unicode glyphs (curly quotes, ellipsis, arrows, emoji) as literal characters in JSX —
`\uXXXX` escapes render verbatim in JSX text.