Distortion✨ Premium

Rainbow Refraction

A frosted glass pane that blurs whatever is behind it, with a conic rainbow slowly spinning inside, like light through a prism.

CSSRainbowSpin

Updated

This effect is part of Effect.Labs — 840 vanilla effects, some free, some premium. Distortion has 31 effects, including 5 free. Explore the category →

3 usage examples

Glass tooltip over a grow light's spectrum (Clorivane) — Rainbow Refraction example 1

① Glass tooltip over a grow light's spectrum (Clorivane)

WhenOn the CV-240 panel's data sheet, the spectrum curve runs from violet to far red; on hover, a small glass pane follows the pointer and shows the wavelength, its colour and the intensity at that spot.
WhyThe glass blurs the coloured curve right below it without hiding it, and the spinning rainbow echoes the page's subject: light split into colours.
Settings136×60 px pane (--rfr-w, --rfr-h), 12 px corners, blur cut to 7 px, rainbow at 34%, white veil at 12%, border at 35%, text lifted above the disc (z-index: 1), root with no background or minimum height. The position under the pointer and the values come from the page; with no mouse, the scene sweeps the curve.
Large glass panel on a light festival's hero (Lucenvail) — Rainbow Refraction example 2

② Large glass panel on a light festival's hero (Lucenvail)

WhenIn front of a night city swept by coloured beams, a glass panel fills the lower part of the hero and carries the dates, the title and two links.
WhyThe glass blurs the city lights without hiding them, and the spinning rainbow announces what the festival is about.
Settings492×206 px panel (--rfr-w: 100%), 22 px corners, blur raised to 14 px, rotation slowed to 9 s, white veil cut to 7%.
Payment being confirmed in a concert ticket shop (Sonquarre) — Rainbow Refraction example 3

③ Payment being confirmed in a concert ticket shop (Sonquarre)

WhenOn a click on "Pay €78.40", the button gives way to a same-size rainbow glass pane reading "Confirming payment…" until the confirmation appears.
WhyThe fast-turning disc shows that something is in progress, exactly where the user just clicked.
Settings100% × 46 px pane, 12 px corners, rainbow at 45%, one turn every 2.5 s. Swapping button, waiting state and confirmation is done by the page.

How it works

The .rfr-glass pane (250×150 px, 20 px corners) has a 10% white fill and a 20% white border. backdrop-filter: blur(10px) blurs everything behind it on the page: a photo, an illustration, lights.

Inside, a square ::before pseudo-element, twice as wide as the pane and centred on it, carries a conic gradient running round the colour wheel (red, orange, yellow, green, cyan, blue, violet, pink). At 30% opacity it makes a full turn in 6 seconds (rfrSpin); the pane clips whatever sticks out.

This disc is drawn above the content, which picks up its tints. To keep text or a button crisp, give your content position: relative and z-index: 1. The disc lets clicks through. Repair: it used to be 150% of the width and height and left two dark corners as it turned; it is now square and covers the whole pane.

Accessibility

  • Real text: "REFRACT" and any content placed in the pane stay HTML text that reads normally.
  • Reduced motion: with prefers-reduced-motion: reduce the rainbow freezes; the pane keeps its colours and blur (measured: 2 looping animations → 0 for two copies).
  • Legibility: under the 30% disc, bold white text stays readable; for body text or a stronger opacity, lift the content above the disc (z-index: 1).
  • No interaction of its own: the pane reacts to neither hover nor keyboard; links and buttons placed inside work normally, keyboard included.

Browser compatibility

CSS only, no JavaScript. Measured in Chromium 151, Firefox 153 and Playwright's WebKit 26.5: 0 errors, corners covered, two independent copies, nothing overflowing at 390 px, disc stopped under reduced motion. Minimum versions come from aspect-ratio (square disc) and, for Firefox, from backdrop-filter (the -webkit- prefix is included for Safari).

Chrome 88+✓ Full (measured)
Firefox 103+✓ Full (measured)
Safari 15+✓ Full (measured in Playwright's WebKit)
Edge 88+✓ Full (Chromium engine)
Safari iOS 15+✓ Full (same engine as Safari)
Chrome Android 88+✓ Full (Chromium engine)

Without backdrop-filter, whatever is behind the pane stays sharp under its white veil; the rainbow still spins.

The code

HTML structure to paste into your page (the CSS + JS come with your purchase):

index.html — structure
<div class="fx-0267-root">
  <div class="rfr-glass">REFRACT</div>
</div>

One-time payment, no subscription — the code is yours forever

Customize

Options passed to the API or data-* attributes:

Option / propertyDefaultEffect
--rfr-w and --rfr-h 250px and 150px Pane size; 100% to follow the container (never wider than it). The disc covers the pane as long as its height stays under 1.7 times its width.
--rfr-radius 20px Corner rounding.
--rfr-glass and --rfr-edge white at 10% and white at 20% Pane veil and border colour.
--rfr-blur 10px Strength of the blur applied to what lies behind the pane.
--rfr-rainbow .3 Rainbow opacity.
--rfr-speed 6s Length of one full turn of the disc.
--rfr-bg and --rfr-min-h #0a0a0f and 300px Root background and minimum height; transparent and 0 so the glass blurs your own page.

FAQ

The blur applies to what is behind: on a plain background there is nothing to blur. Set --rfr-bg: transparent and place the pane over an image or a decor to see the glass effect.
Wrap your content in an element with position: relative and z-index: 1: it then sits above the rainbow instead of being tinted by it.
Not through a variable: the eight colours are written in the conic-gradient of .rfr-glass::before. You can replace them in the CSS, keeping the same colour at the start and the end to avoid a seam.