: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
/*
* Quill ↔ PostHog integration bridge.
*
* Two scopes — read carefully before editing:
*
* - `:root` block: maps Quill's portal z-index tokens (`--quill-z-*`) onto
* PostHog's existing `--z-*` scale. Set globally so the vars cascade
* into portal subtrees mounted at `<body>`. See base.scss for the
* PostHog scale.
*
* - `[data-quill]` block: rebinds colour vars inside Quill subtrees only.
* Two reasons for the scoping:
*
* 1. TOKEN NAME COLLISION. Both `@posthog/tailwind` and `@posthog/quill`
* compile a `bg-muted` utility class, but they reference different
* CSS custom properties (`var(--muted-3000)` vs `var(--muted)`).
* PostHog's compiled CSS wins globally because the class name is
* identical. We can't change which `var(--xyz)` the class points
* at, but we *can* redefine PostHog's `--xyz` value inside
* `[data-quill]` to whatever quill expects. Inside the subtree the
* class resolves to the quill colour; outside, it keeps PostHog's.
*
* 2. MISSING UTILITIES. Quill primitives use class names PostHog's
* tailwind config never declared (`bg-popover`, `bg-card`,
* `bg-background`, `text-foreground`, `text-muted-foreground`,
* `border-border`, etc.). PostHog's pre-compiled bundle therefore
* emits no rule for them and the elements render unstyled. We
* register them as plain CSS rules pointing at quill's tokens.
*
* - `[data-quill] [data-not-quill]` escape hatch: cancels the colour
* rebindings for nested non-quill subtrees so PostHog primitives
* rendered inside a quill panel (e.g. `DatabaseTablePreview`,
* `LemonSelect`, monaco) keep their original colours. CSS variable
* resolution is lazy at use site, so we can't snapshot the originals
* into an alias — the only working approach is to re-bind back to
* base.scss's underlying source-of-truth tokens. Mirror every entry
* in `[data-quill]` here, plus a `[theme="dark"]` variant for the
* dark-theme branches.
*
* Long-term plan: rename quill's colour tokens to `--quill-*` so the
* `[data-quill]` colour rebindings become unnecessary. Tracked separately.
* Until then, this file is the single integration seam — every new colour
* utility quill introduces lands here.
*/
/*
* Z-index mapping: slot Quill's portal layers into PostHog's existing scale.
* Set on `:root` (not just `[data-quill]`) so the vars cascade into portal
* subtrees mounted at `<body>`. See base.scss for the PostHog `--z-*` scale.
*/
:root {
--quill-z-popover: var(--z-popover);
--quill-z-tooltip: var(--z-tooltip);
--quill-z-modal: var(--z-modal);
--quill-z-overlay: var(--z-modal);
--quill-z-toast: var(--z-bottom-notice);
/* PostHog's icons draw thinner lines than lucide's, so quill's selection check matches their weight. */
--quill-indicator-stroke-width: 1.5;
}
[data-quill] {
/*
* Override #1: rebind PostHog vars that already-compiled `bg-*` /
* `text-*` classes resolve at runtime, so the same class flips meaning
* inside a quill subtree. Map LHS = PostHog name, RHS = quill name.
*
* NOTE: we deliberately do NOT rebind `--muted-3000` here. PostHog uses
* the single `--muted-3000` token for both `bg-muted` (surface) and
* `text-muted` (muted text), whereas quill splits these into `--muted`
* (surface) and `--muted-foreground` (text). Pointing `--muted-3000` at
* quill's surface token turned every PostHog `text-muted` inside a quill
* subtree into a near-invisible surface colour (dark grey on the dark
* background). We keep `--muted-3000` theme-aware and instead pin only
* the `.bg-muted` class to quill's surface below.
*/
/*
* Inside `[data-quill]`, `bg-primary` means quill's BRAND colour, not
* PostHog's page surface — PostHog and quill happen to share the class
* name but use it for different semantics. We rebind PostHog's
* `--color-bg-primary` so the compiled `.bg-primary` rule resolves to
* quill's `--primary` here. Code outside `[data-quill]` is unaffected.
*/
--color-bg-primary: var(--primary);
--color-bg-surface-primary: var(--background);
--color-bg-surface-secondary: var(--card);
--color-bg-surface-tertiary: var(--chrome);
--color-text-primary: var(--foreground);
--color-text-secondary: var(--muted-foreground);
--color-border-primary: var(--border);
--color-border-secondary: var(--border);
--color-accent: var(--primary);
--color-accent-hover: var(--primary);
--color-accent-active: var(--primary);
}
/*
* Reset various annoying global styles from global styles.
*/
[data-quill] p,
[data-quill] h2 {
margin-bottom: 0;
}
/*
* Override #2: register the quill-only utilities PostHog's compiler skipped.
* Scoped to `[data-quill]` so they don't pollute the rest of the app.
* Specificity (0,2,0) beats Tailwind's plain class (0,1,0), so these always
* win inside the subtree even if PostHog later adds a same-named class.
*/
[data-quill].bg-background,
[data-quill] .bg-background {
background-color: var(--background);
}
[data-quill].bg-card,
[data-quill] .bg-card {
background-color: var(--card);
}
/*
* `bg-muted` collides: PostHog's compiled rule reads `--muted-3000`, quill's
* reads `--muted`. Pin the class to quill's muted surface inside the subtree
* without hijacking `--muted-3000` (which `text-muted` also depends on).
* PostHog's utilities are `!important` in a layer, so this rule must be too, in the same layer.
*/
@layer utilities {
[data-quill].bg-muted,
[data-quill] .bg-muted {
background-color: var(--muted) !important;
}
}
[data-quill].bg-popover,
[data-quill] .bg-popover {
background-color: var(--popover);
}
[data-quill].bg-input,
[data-quill] .bg-input {
background-color: var(--input);
}
[data-quill].bg-fill-hover,
[data-quill] .bg-fill-hover {
background-color: var(--fill-hover);
}
[data-quill].bg-fill-selected,
[data-quill] .bg-fill-selected {
background-color: var(--fill-selected);
}
[data-quill].bg-fill-expanded,
[data-quill] .bg-fill-expanded {
background-color: var(--fill-expanded);
}
/* stylelint-disable selector-class-pattern -- the name of Tailwind's hover variant class */
[data-quill].hover\:bg-fill-selected:hover,
[data-quill] .hover\:bg-fill-selected:hover {
background-color: var(--fill-selected);
}
/* stylelint-enable selector-class-pattern */
/*
* Use this for a quill hover fill, not `hover:bg-muted`. PostHog's compiled `hover:bg-muted` reads `--muted-3000`,
* a dark text colour, and it is `!important` inside a cascade layer, so no rule in this file can override it.
*/
/* stylelint-disable selector-class-pattern -- the name of Tailwind's hover variant class */
[data-quill].hover\:bg-fill-hover:hover,
[data-quill] .hover\:bg-fill-hover:hover {
background-color: var(--fill-hover);
}
/* stylelint-enable selector-class-pattern */
[data-quill].bg-destructive-foreground,
[data-quill] .bg-destructive-foreground {
background-color: var(--destructive-foreground);
}
[data-quill].bg-foreground,
[data-quill] .bg-foreground {
background-color: var(--foreground);
}
[data-quill].bg-muted-foreground,
[data-quill] .bg-muted-foreground {
background-color: var(--muted-foreground);
}
[data-quill].text-foreground,
[data-quill] .text-foreground {
color: var(--foreground);
}
[data-quill].text-foreground\/70,
[data-quill] .text-foreground\/70 {
color: color-mix(in oklab, var(--foreground) 70%, transparent);
}
/* stylelint-disable selector-class-pattern -- the name of Tailwind's hover variant class */
[data-quill].hover\:text-foreground:hover,
[data-quill] .hover\:text-foreground:hover {
color: var(--foreground);
}
/* stylelint-enable selector-class-pattern */
[data-quill].text-muted-foreground,
[data-quill] .text-muted-foreground {
color: var(--muted-foreground);
}
[data-quill].text-background,
[data-quill] .text-background {
color: var(--background);
}
[data-quill].text-subtle-foreground,
[data-quill] .text-subtle-foreground {
color: var(--subtle-foreground);
}
[data-quill].text-card-foreground,
[data-quill] .text-card-foreground {
color: var(--card-foreground);
}
[data-quill].text-popover-foreground,
[data-quill] .text-popover-foreground {
color: var(--popover-foreground);
}
[data-quill].text-primary-foreground,
[data-quill] .text-primary-foreground {
color: var(--primary-foreground);
}
[data-quill].text-primary-on-foreground,
[data-quill] .text-primary-on-foreground {
color: var(--primary-on-foreground);
}
[data-quill].text-destructive-foreground,
[data-quill] .text-destructive-foreground {
color: var(--destructive-foreground);
}
[data-quill].text-success-foreground,
[data-quill] .text-success-foreground {
color: var(--success-foreground);
}
[data-quill].text-info-foreground,
[data-quill] .text-info-foreground {
color: var(--info-foreground);
}
[data-quill].text-warning-foreground,
[data-quill] .text-warning-foreground {
color: var(--warning-foreground);
}
[data-quill].text-completed-foreground,
[data-quill] .text-completed-foreground {
color: var(--completed-foreground);
}
[data-quill].text-accent-foreground,
[data-quill] .text-accent-foreground {
color: var(--accent-foreground);
}
[data-quill].border-border,
[data-quill] .border-border {
border-color: var(--border);
}
[data-quill].border-muted-foreground,
[data-quill] .border-muted-foreground {
border-color: var(--muted-foreground);
}
[data-quill].border-foreground,
[data-quill] .border-foreground {
border-color: var(--foreground);
}
/* stylelint-disable selector-class-pattern -- the name of Tailwind's hover variant class */
[data-quill].hover\:border-foreground:hover,
[data-quill] .hover\:border-foreground:hover {
border-color: var(--foreground);
}
/* stylelint-enable selector-class-pattern */
[data-quill].border-input,
[data-quill] .border-input {
border-color: var(--input);
}
[data-quill].border-ring,
[data-quill] .border-ring {
border-color: var(--ring);
}
/* stylelint-disable selector-class-pattern -- the name of Tailwind's focus-visible variant class */
[data-quill].focus-visible\:outline-ring:focus-visible,
[data-quill] .focus-visible\:outline-ring:focus-visible {
outline-color: var(--ring);
}
/* stylelint-enable selector-class-pattern */
/*
* Tailwind ring utilities with quill colour names. `ring-1`, `ring-2`, etc.
* are structural (PostHog's compiled bundle has them) and read
* `--tw-ring-color` at runtime — we override that variable inside
* `[data-quill]` so the colour part (`ring-foreground`, `ring-ring`) lands
* even though PostHog's tailwind config never declared those names.
*/
[data-quill].ring-foreground,
[data-quill] .ring-foreground {
--tw-ring-color: var(--foreground);
}
[data-quill].ring-foreground\/10,
[data-quill] .ring-foreground\/10 {
--tw-ring-color: color-mix(in oklab, var(--foreground) 10%, transparent);
}
[data-quill].ring-foreground\/20,
[data-quill] .ring-foreground\/20 {
--tw-ring-color: color-mix(in oklab, var(--foreground) 20%, transparent);
}
[data-quill].ring-border,
[data-quill] .ring-border {
--tw-ring-color: var(--border);
}
[data-quill].ring-background,
[data-quill] .ring-background {
--tw-ring-color: var(--background);
}
[data-quill].ring-ring,
[data-quill] .ring-ring {
--tw-ring-color: var(--ring);
}
[data-quill].ring-ring\/30,
[data-quill] .ring-ring\/30 {
--tw-ring-color: color-mix(in oklab, var(--ring) 30%, transparent);
}
[data-quill].ring-destructive\/20,
[data-quill] .ring-destructive\/20 {
--tw-ring-color: color-mix(in oklab, var(--destructive) 20%, transparent);
}
/*
* ---- [data-not-quill] escape hatch ---------------------------------------
*
* When non-quill PostHog content is rendered inside a quill subtree (e.g.
* the DataWarehouseTablePreview, LemonSelect, monaco, or any legacy
* component), wrap it in `data-not-quill` to restore PostHog's colour
* system inside that subtree.
*
* Specificity (0,2,0) of `[data-quill] [data-not-quill]` beats `[data-quill]`
* (0,1,0), so these rebindings always win for nested content. The values
* mirror what base.scss sets at `:root` / `[theme="dark"]` — duplicating
* them is unfortunate but lazy CSS variable evaluation makes a snapshot
* impossible.
*/
[data-quill] [data-not-quill] {
--muted-3000: var(--muted-3000-light);
--color-bg-primary: var(--color-posthog-3000-50);
--color-bg-surface-primary: var(--color-white);
--color-bg-surface-secondary: var(--color-posthog-3000-100);
--color-bg-surface-tertiary: var(--color-posthog-3000-150);
--color-text-primary: var(--color-neutral-950);
--color-text-secondary: var(--color-neutral-750);
--color-border-primary: var(--color-posthog-3000-200);
--color-border-secondary: var(--color-posthog-3000-400);
--color-accent: hsl(
var(--color-brand-primary-hue),
var(--color-brand-primary-saturation),
var(--color-brand-primary-lightness)
);
--color-accent-hover: hsl(
var(--color-brand-primary-hue),
var(--color-brand-primary-saturation),
calc(var(--color-brand-primary-lightness) + 10%)
);
--color-accent-active: hsl(
var(--color-brand-primary-hue),
var(--color-brand-primary-saturation),
calc(var(--color-brand-primary-lightness) + 15%)
);
}
[theme='dark'] [data-quill] [data-not-quill] {
--muted-3000: var(--muted-3000-dark);
--color-bg-primary: var(--color-neutral-cool-950);
--color-bg-surface-primary: var(--color-neutral-cool-850);
--color-bg-surface-secondary: var(--color-neutral-cool-900);
--color-bg-surface-tertiary: var(--color-neutral-cool-950);
--color-text-primary: var(--color-neutral-100);
--color-text-secondary: var(--color-neutral-350);
--color-border-primary: var(--color-neutral-cool-800);
--color-border-secondary: var(--color-neutral-cool-600);
}
/*
* Quill also names two of its status fills `--success` and `--warning`, and tokens.scoped.css
* sets them on every element under [data-quill], not only on the wrapper. So the hatch must
* set Lemon's values on each descendant too, or LemonTag and LemonBanner text turns pale.
* base.scss gives these one value for both themes.
*/
[data-quill] [data-not-quill],
[data-quill] [data-not-quill] * {
--success: #388600;
--warning: #f7a501;
}
/*
* Icon size. `.LemonIcon { width: 1em }` in icons.scss sits outside any layer, so it beats quill's layered icon size
* and leaves a PostHog icon in a quill button narrower than it is tall. That shifts the label off the column the other
* rows use. Inside a quill button, the width goes back to quill, which sets width and height together.
*/
.quill-button .LemonIcon:not([class*='size-']) {
width: revert-layer;
}