# Fluted Glass

> Soft colour glowing through ribbed glass: each rib bends and frosts the light behind it, and one glow leans towards the cursor. CSS only.

Category: Backgrounds · Free · Updated 2026-11-09 · Live demo: https://www.motionkitui.com/components/fluted-glass

## When to use it

Fashion, beauty, architecture and interiors sites, premium SaaS heroes and pricing pages, and anywhere a soft, tactile backdrop beats a flat gradient.

## How it works

Three blurred radial glows drift on their own CSS keyframe loops, and a fourth leans towards the pointer through a CSS variable, so nothing re-renders as you move. The glass is a row of ribs, and each one holds its own copy of the glows, shifted so it lines up with the whole and then stretched about the rib's centre. Because each rib stretches about a different point, the colour jumps at every edge, which is exactly how fluted glass breaks up what's behind it. A light-to-dark gradient on each rib suggests its curve, and fine grain stops the gradients banding.

## Installation

```bash
npx shadcn@latest add https://www.motionkitui.com/r/fluted-glass.json
```

Or copy `components/motionkit/fluted-glass.tsx` below. Requires react and Tailwind CSS v4. Free for personal projects; commercial use needs MotionKit Plus (https://www.motionkitui.com/pricing).

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `colors` | `[string, string, string, string]` | `["#F2B8A2", "#B79AD3", "#5FAEB4", "#E9C46A"]` | The four glows behind the glass; the last one follows the pointer. |
| `ribs` | `number` | `14` | Number of ribs across the glass. |
| `refraction` | `number` | `1.35` | How much each rib stretches the light, 1 for flat glass. |
| `frost` | `number` | `6` | Blur behind the glass, in pixels. |
| `duration` | `number` | `18` | Seconds for the glows to make one slow loop. |
| `interactive` | `boolean` | `true` | Let one glow lean towards the pointer. |
| `children` | `ReactNode` |  | Your content, layered above. |

## Accessibility

- **Keyboard: Not applicable.** Decorative, nothing to focus.
- **Screen readers: Pass.** The effect is hidden from assistive tech; only your content is read.
- **Reduced motion: Pass.** With reduced motion on, the glows stop drifting and the glass shows a still composition.
- **Colour contrast: Pass.** The glows are bright pastels, so give text a dark backing or use dark text; the dark base between them measures 17:1 with ivory.

## Source

```tsx
"use client";

import { useRef, type CSSProperties, type PointerEvent, type ReactNode } from "react";

type FlutedGlassProps = {
  children?: ReactNode;
  /** Four colours glowing behind the glass. */
  colors?: [string, string, string, string];
  /** Number of ribs across the glass. */
  ribs?: number;
  /** How much each rib bends the light behind it, 1 for flat glass. */
  refraction?: number;
  /** Frosting, in pixels of blur. */
  frost?: number;
  /** Seconds for the colours to make one slow loop. */
  duration?: number;
  /** Let one of the glows drift towards the pointer. */
  interactive?: boolean;
  className?: string;
};

// one loop per glow, so they never line up the same way twice
const KEYFRAMES = `
@keyframes fluted-a{0%,100%{transform:translate(0,0) scale(1)}33%{transform:translate(18%,12%) scale(1.15)}66%{transform:translate(-10%,20%) scale(.9)}}
@keyframes fluted-b{0%,100%{transform:translate(0,0) scale(1)}33%{transform:translate(-22%,-8%) scale(.85)}66%{transform:translate(12%,-16%) scale(1.2)}}
@keyframes fluted-c{0%,100%{transform:translate(0,0) scale(1.1)}50%{transform:translate(-16%,14%) scale(.9)}}
@media (prefers-reduced-motion:reduce){.fluted-glow{animation:none!important}}`;

/**
 * Colour glowing through ribbed glass. Soft lights drift behind, and every rib holds its own stretched, frosted copy
 * of them, so the colour bends and breaks at each edge the way real fluted glass does. CSS only, no canvas.
 */
export function FlutedGlass({
  children,
  colors = ["#F2B8A2", "#B79AD3", "#5FAEB4", "#E9C46A"],
  ribs = 14,
  refraction = 1.35,
  frost = 6,
  duration = 18,
  interactive = true,
  className = "",
}: FlutedGlassProps) {
  const ref = useRef<HTMLDivElement>(null);
  const count = Math.max(2, Math.round(ribs));

  function move(event: PointerEvent) {
    if (!interactive || event.pointerType === "touch") return;
    const rect = ref.current!.getBoundingClientRect();
    ref.current!.style.setProperty("--fluted-x", `${((event.clientX - rect.left) / rect.width - 0.5) * 60}%`);
    ref.current!.style.setProperty("--fluted-y", `${((event.clientY - rect.top) / rect.height - 0.5) * 60}%`);
  }

  // the lights behind the glass; drawn once whole and once inside every rib
  const glows = (
    <>
      <span
        className="fluted-glow absolute rounded-full"
        style={{ width: "70%", height: "90%", left: "-10%", top: "-20%", background: `radial-gradient(closest-side, ${colors[0]}, transparent)`, animation: `fluted-a ${duration}s ease-in-out infinite` }}
      />
      <span
        className="fluted-glow absolute rounded-full"
        style={{ width: "65%", height: "85%", right: "-12%", top: "5%", background: `radial-gradient(closest-side, ${colors[1]}, transparent)`, animation: `fluted-b ${duration * 1.3}s ease-in-out infinite` }}
      />
      <span
        className="fluted-glow absolute rounded-full"
        style={{ width: "60%", height: "80%", left: "15%", bottom: "-35%", background: `radial-gradient(closest-side, ${colors[2]}, transparent)`, animation: `fluted-c ${duration * 0.8}s ease-in-out infinite` }}
      />
      {/* this one leans towards the pointer */}
      <span className="absolute inset-0 transition-transform duration-[1.6s] ease-out" style={{ transform: "translate(var(--fluted-x, 0%), var(--fluted-y, 0%))" }}>
        <span className="absolute rounded-full" style={{ width: "40%", height: "55%", left: "30%", top: "22%", background: `radial-gradient(closest-side, ${colors[3]}, transparent)`, opacity: 0.85 }} />
      </span>
    </>
  );

  return (
    <div
      ref={ref}
      onPointerMove={move}
      onPointerLeave={() => {
        ref.current?.style.setProperty("--fluted-x", "0%");
        ref.current?.style.setProperty("--fluted-y", "0%");
      }}
      className={`relative isolate overflow-hidden bg-[#0C1010] ${className}`}
    >
      <style>{KEYFRAMES}</style>
      <div aria-hidden className="absolute inset-0 -z-10">
        {Array.from({ length: count }, (_, index) => {
          const rib: CSSProperties = { left: `${(index / count) * 100}%`, width: `${100 / count}%` };
          // the copy behind this rib spans the whole glass, shifted so it lines up, then stretched about the rib's centre
          const inner: CSSProperties = {
            width: `${count * 100}%`,
            left: `${-index * 100}%`,
            transform: `scaleX(${refraction})`,
            transformOrigin: `${((index + 0.5) / count) * 100}% 50%`,
            filter: `blur(${frost}px) saturate(1.2)`,
          };
          return (
            <div key={index} className="absolute inset-y-0 overflow-hidden" style={rib}>
              <div className="absolute inset-y-0" style={inner}>
                {glows}
              </div>
              {/* each rib is lit on one side and shaded on the other, which sells the curve */}
              <div className="absolute inset-0 bg-[linear-gradient(90deg,rgb(255_255_255/0.14),rgb(255_255_255/0.03)_30%,transparent_55%,rgb(0_0_0/0.28))]" />
              <div className="absolute inset-y-0 right-0 w-px bg-black/30" />
            </div>
          );
        })}
        {/* grain keeps the gradients from banding */}
        <div
          className="absolute inset-0 opacity-[0.07] mix-blend-overlay"
          style={{ backgroundImage: "url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E\")" }}
        />
      </div>
      {children}
    </div>
  );
}
```
