# Gold Foil

> Lettering hot-stamped in metal foil, in gold, rose, champagne or silver: banded tones, a fine grain, a soft emboss, and a highlight that follows the cursor.

Category: Text · Free · Updated 2026-11-09 · Live demo: https://www.motionkitui.com/components/gold-foil-text

## When to use it

Luxury brand names and logotypes, invitations and save-the-dates, award winners, VIP tiers and premium plan names.

## How it works

The letters are clipped to a stack of backgrounds with background-clip: text, so they stay real, selectable text. The bottom layer is a gradient with alternating dark and bright bands, which is what reads as metal; a fine noise texture blended over it gives the grain of stamped foil. Above them, a narrow band of light slides across on a slow loop, and a soft radial highlight follows the pointer through CSS variables, while the bands tilt slightly as if the foil were turned. Three drop shadows make the emboss.

## Installation

```bash
npx shadcn@latest add https://www.motionkitui.com/r/gold-foil-text.json
```

Or copy `components/motionkit/gold-foil-text.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 |
| --- | --- | --- | --- |
| `children` | `ReactNode` |  | The text. |
| `foil` | `"gold" \| "rose" \| "champagne" \| "silver"` | `"gold"` | The metal. |
| `as` | `ElementType` | `"span"` | Element to render, e.g. h1. |
| `sweep` | `number` | `6` | Seconds between slow sweeps of light. 0 turns them off. |
| `interactive` | `boolean` | `true` | Let the light follow the pointer. |

## Accessibility

- **Keyboard: Not applicable.** Text, not a control.
- **Screen readers: Pass.** It's your real text in the element you choose, read normally; the foil is only a background.
- **Reduced motion: Pass.** With reduced motion on, the sweep stops; the pointer's highlight still follows, as it moves only when you do.
- **Colour contrast: Partial.** On a dark page most of each letter measures 5.2:1 to 14:1 depending on the foil, but the deepest band at the very edge of the gradient drops to 1.9:1. Use it for large headings, where 3:1 is the bar.

## Source

```tsx
"use client";

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

const FOILS = {
  gold: ["#5C3A0E", "#B8862B", "#F6DC8E", "#FFF6D8", "#C9962F", "#7A5216"],
  rose: ["#5A2A24", "#B8735F", "#F2C2AE", "#FFF0E8", "#C98A75", "#7A3F33"],
  champagne: ["#4F4231", "#A8916E", "#EADBC0", "#FFFBF1", "#BBA67F", "#6E5D45"],
  silver: ["#2E3236", "#8D949B", "#DDE2E6", "#FFFFFF", "#A4ABB2", "#4E5459"],
} as const;

type GoldFoilTextProps = {
  children: ReactNode;
  /** The metal. */
  foil?: keyof typeof FOILS;
  /** The element to render, e.g. "h1". */
  as?: ElementType;
  /** Let the light follow the pointer across the letters. */
  interactive?: boolean;
  /** Seconds between slow sweeps of light while the pointer is elsewhere. 0 turns them off. */
  sweep?: number;
  className?: string;
};

// a fine grain makes it read as stamped foil rather than a flat gradient
const GRAIN =
  "url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .5 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E\")";

/**
 * Lettering hot-stamped in metal foil. Banded metallic tones and a fine grain give it the look of real foil, a soft
 * emboss lifts it off the page, and a highlight follows the pointer across the letters, or sweeps by now and then.
 */
export function GoldFoilText({ children, foil = "gold", as: Tag = "span", interactive = true, sweep = 6, className = "" }: GoldFoilTextProps) {
  const ref = useRef<HTMLElement>(null);
  const [deep, base, light, peak, mid, dark] = FOILS[foil];

  function move(event: PointerEvent) {
    if (!interactive || event.pointerType === "touch") return;
    const rect = ref.current!.getBoundingClientRect();
    const x = ((event.clientX - rect.left) / rect.width) * 100;
    const y = ((event.clientY - rect.top) / rect.height) * 100;
    ref.current!.style.setProperty("--foil-x", `${x}%`);
    ref.current!.style.setProperty("--foil-y", `${y}%`);
    // the metal's bands tilt a little with the light, as a foil does when you turn it
    ref.current!.style.setProperty("--foil-angle", `${100 + (x - 50) * 0.5}deg`);
    ref.current!.dataset.lit = "";
  }

  function leave() {
    delete ref.current?.dataset.lit;
    ref.current?.style.setProperty("--foil-angle", "100deg");
  }

  const style = {
    "--foil-x": "50%",
    "--foil-y": "30%",
    "--foil-angle": "100deg",
    backgroundImage: [
      // the pointer's highlight, faded in only while the pointer is over the text
      "radial-gradient(circle at var(--foil-x) var(--foil-y), rgb(255 255 255 / var(--foil-glow, 0)), transparent 32%)",
      // the slow sweep of light
      sweep ? "linear-gradient(110deg, transparent 42%, rgb(255 255 255 / 0.75) 50%, transparent 58%)" : "linear-gradient(transparent, transparent)",
      GRAIN,
      `linear-gradient(var(--foil-angle), ${deep} 0%, ${base} 18%, ${light} 34%, ${peak} 42%, ${mid} 55%, ${light} 70%, ${base} 82%, ${dark} 100%)`,
    ].join(", "),
    backgroundSize: "100% 100%, 300% 100%, 160px 160px, 100% 100%",
    backgroundPosition: "0 0, 150% 0, 0 0, 0 0",
    backgroundBlendMode: "normal, normal, soft-light, normal",
    WebkitBackgroundClip: "text",
    backgroundClip: "text",
    color: "transparent",
    // the emboss: a bright lip above and a soft shadow below, as stamped foil sits on paper
    filter: `drop-shadow(0 -1px 0 rgb(255 248 225 / 0.25)) drop-shadow(0 1.5px 1px rgb(0 0 0 / 0.55)) drop-shadow(0 6px 14px ${dark}66)`,
    animation: sweep ? `foil-sweep ${sweep}s ease-in-out infinite` : undefined,
  } as CSSProperties;

  return (
    <>
      <style>{`@keyframes foil-sweep{0%,55%{background-position:0 0,150% 0,0 0,0 0}100%{background-position:0 0,-50% 0,0 0,0 0}}[data-foil][data-lit]{--foil-glow:.85}@media (prefers-reduced-motion:reduce){[data-foil]{animation:none!important}}`}</style>
      <Tag ref={ref} data-foil="" onPointerMove={move} onPointerLeave={leave} className={`inline-block ${className}`} style={style}>
        {children}
      </Tag>
    </>
  );
}
```
