In short: every color on the page becomes a CSS variable, and a new palette rewrites the variables

How Recolor repaints a page

Recolor (recolor.page) works in three moves: it fetches a page through its own Worker, shows it in a sandboxed frame and rewrites every color the page uses into a CSS variable that still holds the original. A new palette then changes only those variables, in one write, so the page repaints a few milliseconds after you press Space. That repaint is the product: Recolor is a website color changer, and the palette is its input.

Last updated

From Recolor's code (src/worker, src/engine, src/shared/mapping.ts), checked November 13, 2026
StepWhat happensWhere
1. FetchThe Worker fetches the page (up to 5 MB), puts its stylesheets inline and adds the engine scriptCloudflare Worker
2. ShowThe app puts the prepared page in a sandboxed frame: its scripts may run, but cannot reach RecolorYour browser
3. ReadThe engine reads every color in the stylesheets, inline styles and SVG attributes, shadow DOM and SVG pictures included, and weighs how much of the page each coversThe page
4. RewriteEach exact color becomes its own CSS variable, set to the original, so the page looks unchangedThe page
5. GroupColors within 0.04 in OKLab form a cluster; clusters within 25 degrees of hue form a familyThe page and the app
6. MapThe page's background and text take the lightest and darkest swatches, families the others by rank, text keeps its contrastThe app
7. RepaintOne write sets every variable; the browser restyles the pageThe page

Three parts: the app, the Worker and the engine

The app is what you see: the toolbar, the preview and the palette beside it. It generates palettes, keeps history, and works out which palette color each page color becomes.

The Worker runs on Cloudflare under the same address as the app. It fetches the page you asked for, puts every stylesheet it can fetch inline, rewrites relative addresses so images and fonts still load, and adds two scripts at the top of the page: a small configuration and the engine. With the Scripts switch off it also removes the page's own scripts. What it fetches, and what it never keeps, is on What Recolor stores and fetches.

The engine is a 107.9 KB script that runs inside the previewed page. It reads the page's colors, rewrites them into variables, reports what it found to the app, and applies each new palette.

The preview is an iframe with sandbox="allow-scripts" and the page in its srcdoc. The page's scripts can run, but the frame has no origin of its own, so they cannot read Recolor's storage, open windows or submit forms. The engine and the app talk only through messages.

What happens when a page loads

The engine starts when the page's HTML has been parsed. It walks every stylesheet it can read, including media queries, layers, container queries, nested rules, keyframes and imports, plus inline styles and the colors SVG and old HTML set by attribute (fill, stroke, stop-color, bgcolor and the like). It reads the same inside shadow DOM, where web components keep their styles: every open shadow root, and every root a page script makes, closed ones too. For each color it counts how many elements the rule reaches, and gives backgrounds extra weight by their area, so the color of a hero outweighs the color of a hairline border.

Every exact color gets its own CSS variable, such as --rc-c3m1, and every declaration that used it is rewritten to point at that variable. The variables start at the page's own values, in its own notation, so before a palette arrives the page keeps its look: with scripts off, on all 16 sites tested on October 8, 2026, no computed color moved by more than 0.02 in OKLab, too little to see. Colors closer than 0.04 in OKLab are reported as one cluster, which is what the app ranks and what the Site colours panel lists.

Some themes keep a color as three bare numbers in a custom property and build it where it is used, as Shopify's free themes, Squarespace 7.1 and Wix do: --color-background: 255,255,255 with rgb(var(--color-background)). The engine reads such a property as a color once a color function reads it, and points it at a variable that holds the numbers in the same form, so an alpha the page adds where it uses the color, as in rgba(var(--color-background), .5), keeps working, and so does one written after the numbers, as in --background: 255 255 255 / 1.0.

A logo, an icon or a background drawn in SVG is a picture, but its colors are written in its text. The engine reads the SVG behind every image that shows one and every SVG url() in a background, a border image, a list marker or content, as text and without running it, and counts each color it paints by where the picture shows, so a logo joins its brand's family. Under a palette it writes the picture again in the new colors and shows that copy; the page's own picture, and its src for the page's scripts, stay as they were. While you drag a slider, the colors follow at once and the pictures a few a frame, a pass at most every 100 ms. The Recolor SVG pictures switch in the Mapping panel, and Use site colours, give every picture back as the page drew it.

The browser paints a few colors no rule of the page sets: the canvas behind a page without a background of its own, the text of a page without a text color, links and marked text. The engine writes those as rules of its own, below every page style, so they look the same as before and take the palette as the page's own colors do.

One thing the engine changes before any palette: Wix holds a section with an entrance effect invisible until its own scripts play the effect, which they never do in the preview. The engine marks such a section the way Wix does once the effect has played, so it shows as a visitor sees it; other animations are left as they are.

The engine also notes which text sits on which background, so the mapping can keep it readable, and it keeps watching: rules and elements that scripts add later are read in batches 100 ms after they appear. The foot of the palette then shows what it found, for example "26 colours, 1 sheet, 22 ms". How long that takes on real sites is on Which sites load; the size limits are on Limits.

What happens when you press Space

Space generates a new palette in the app: a color scheme, a ladder of lightness from dark to light, and neighbors kept at least 0.08 apart in OKLab. Locked colors stay. The app then maps the page:

  • Chromatic clusters within 25 degrees of hue form a family, so a brand's shades, its hover color and the stops of its gradient move together.
  • With Greys on Palette, the default, the page's background moves towards the lightest swatch and its text towards the darkest, the other way round on a dark page, and every other grey keeps its place between the two. On Tint, the look of before, the greys keep their lightness and take a tint of swatch 1 by the Neutral tint setting.
  • Families are ranked by weight times chroma and take the other swatches in order: the first family the first of them, the second the next, and so on.
  • Each color moves towards its swatch by the Strength setting, 70% by default, and large shifts in lightness are held back, so a dark section stays dark.
  • A pale tint or a near-black in the hue of a page color, such as a brand's mint cards or a footer in its near-black, is not a grey: it counts as that color and moves with it.
  • Text is checked against what it sits on and given back lightness until it reads at least as well as before, up to 4.5:1.

The result is a list of variables, posted to the engine and written into the page as one style element. On October 7, 2026 the production build wrote it 3 ms after the key (the median), and on 8 or 9 of 20 presses the page repainted in the same frame as the palette, one frame later otherwise. The mapping itself takes 2 to 4 ms even on github.com, whose page has 1,012 distinct colors. The details and the settings are on Strength, neutral tint and overrides, and the reasoning about lightness on why a dark hero stays dark.

What it cannot repaint

Photos, video, canvas and WebGL keep their colors: they are pixels, not CSS. A photo, a logo saved as PNG or a hero drawn in WebGL stays as it is; the Grey images switch in the Mapping panel greys them out so the palette reads on its own. An SVG picture keeps its colors past the limits on Limits, and so does an image that shows one at another size than its own (a 2x source, or object-fit) or sits inside a shadow root. A closed shadow root written in the page's markup is out of every script's reach, the engine's too, and keeps its colors.

A stylesheet a page's script links as it runs, or one the Worker could not fetch in time, comes through Recolor's sheet route and is read like the rest. One the route cannot bring either is handled element by element: the engine sets the new colors on each element directly, and hover colors from that sheet keep their originals. The same technique, applied by hand to a site you own, is in How to recolor a website with CSS variables.

Common questions

Does Recolor change the website itself?

No. It repaints a copy of the page in your browser. The site, its files and its visitors never see the palette.

Does the page keep working while it is recolored?

Yes, mostly. Links on a page loaded from an address open through Recolor, forms are cancelled, and with the Scripts switch on the page's own scripts run, though scripts other sites load as modules often cannot start in the sandbox.

Does Recolor use AI to pick the colors?

No. Palettes come from color schemes and a lightness ladder in OKLCH, and the mapping follows fixed rules: rank by weight, hue families within 25 degrees, a lightness guard and a contrast check.

Can Recolor recolor images and video?

No, apart from SVG pictures. Photos, video, canvas and WebGL keep their colors; a logo, icon or background drawn in SVG takes the palette. The Grey images switch shows images and video in grey so they do not distract from the palette.

Is the repaint instant on large pages?

Yes, as far as the eye goes. The mapping takes 2 to 4 ms; the browser's restyle afterwards is what grows with the page, 1 to 3 frames after the strip on github.com, with 28,104 declarations.

Does a page pass through a server?

Yes. A page from an address is fetched by Recolor's Worker on Cloudflare, and an uploaded file is sent there to be prepared. Uploads are never stored or cached; a fetched page is cached for 60 seconds.

Sources