: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
// The editor paints its text twice: a backdrop div that can style the `{{variable}}` tokens, and
// the real textarea on top holding the caret and selection. The two layers must lay text out
// identically or the caret lands away from the glyphs under it, so every property that affects
// line breaking is declared once for both.
//
// This is SCSS rather than utility classes because `.LemonTextArea` sets its own font-size,
// line-height, color and background in plain unlayered CSS, which beats Tailwind's layered
// utilities no matter their specificity; and `LemonTextArea` puts its `className` on both its
// wrapper and the textarea, so styling through it would give the wrapper a second copy of the
// padding.
.TemplateVariableTextArea {
position: relative;
// Everything that decides where a line breaks. The two layers must agree on all of it.
// No scrollbar-gutter on purpose: these editors autosize without a row cap, so no scrollbar
// ever appears, and react-textarea-autosize 8.3.4 does not copy the property to its hidden
// measuring textarea, so declaring it would make the measured height drift from the real one.
&__backdrop,
textarea.LemonTextArea {
padding: 0.5rem;
font-family: inherit;
font-size: 0.875rem;
line-height: 1.5;
overflow-wrap: break-word;
white-space: pre-wrap;
}
&__backdrop {
position: absolute;
inset: 0;
// The backdrop is positioned and the field's wrapper is not, so without an explicit order
// the backdrop paints over the field, hiding both the caret and the field's own border.
z-index: 0;
overflow: hidden;
color: var(--color-text-primary);
pointer-events: none;
background-color: var(--color-bg-fill-input);
// Matches the field's 1px border, so both layers wrap text at the same width.
border: 1px solid transparent;
border-radius: var(--radius);
}
// Color only, same weight and size: these spans sit under a transparent textarea, and any
// property that changes glyph advance widths would pull the caret away from the text.
&__variable {
color: var(--color-accent);
}
// The warning color alone reads too close to the accent; the wavy underline makes an
// unfilled token unmistakable, and text-decoration leaves glyph metrics untouched.
&__variable--unfilled {
color: var(--color-text-warning);
text-decoration: underline wavy var(--color-text-warning);
text-underline-offset: 3px;
}
// `LemonTextArea` puts this class on its wrapper and its textarea; both only need to sit
// above the backdrop, and the wrapper must keep the border and padding the design system
// gives it.
&__field {
position: relative;
z-index: 1;
// `.input-like` fills its background on focus, and this layer sits above the backdrop, so
// without this the text vanishes the moment the field is focused. The backdrop owns the
// background; this layer stays glass all the way down.
background-color: transparent;
}
// The backdrop paints the text and the background; the textarea keeps the caret, selection,
// and placeholder.
textarea.LemonTextArea {
color: transparent;
caret-color: var(--color-text-primary);
background-color: transparent;
&::placeholder {
color: var(--color-text-tertiary);
}
}
}