# Gild — Animated Text Effect for React

> A metallic light sweep crosses glyphs on a deliberate slow interval — a white core edged in refined champagne gold over a brushed-bronze base. Pure CSS, driven by an animated @property.

- Page: https://crucibleui.com/components/text/gild
- Category: [text](https://crucibleui.com/components/text)
- Tier: free (full source)
- Engine: css

## Install

```bash
npx shadcn@latest add @crucible/gild
```

Registry JSON: https://crucibleui.com/r/gild.json

Import from `@/components/crucible/gild`.

## Props (`GildProps`)

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `as?` | `"span" \| "div" \| "p" \| "h1" \| "h2" \| "h3"` | `"span"` | Element tag rendered. |
| `colors?` | `GildColors` | — | Gradient stops for the base tone and sweep core/edges. |
| `interval?` | `number` | `4.5` | Seconds between sweeps. |
| `angle?` | `number` | `100` | Sweep angle in degrees. |
| `hoverOnly?` | `boolean` | `false` | Only sweep while hovered, instead of continuously on an interval. |
| `paused?` | `boolean` | `false` | Freeze the sweep at its current frame. |

Also accepts: `React.ComponentPropsWithoutRef<"span">`.

## Usage example

```tsx
import { Gild } from "@/components/crucible/gild";

export default function GildDemo() {
  return (
    <div className="relative isolate flex h-full min-h-[360px] w-full items-center justify-center overflow-hidden rounded-xl bg-neutral-950">
      <div
        aria-hidden
        className="pointer-events-none absolute inset-0 bg-[radial-gradient(ellipse_at_center,rgba(255,255,255,0.035),transparent_70%)]"
      />
      <div className="relative z-10 flex flex-col items-center gap-6 px-6 text-center">
        <h2 className="text-5xl font-bold tracking-tight">
          <Gild as="span">Wait for the sweep</Gild>
        </h2>
        <p className="text-sm text-neutral-500">
          Sweeps only on hover:{" "}
          <span className="font-medium">
            <Gild as="span" hoverOnly interval={1.4}>
              hover over me
            </Gild>
          </span>
        </p>
        <div className="flex flex-col items-center gap-2">
          <p className="text-lg font-medium">
            <Gild
              as="span"
              interval={2.5}
              angle={80}
              colors={{ base: "#5b7c99", core: "#ffffff", amber: "#a5d8ff", ember: "#4098d7" }}
            >
              a faster, steeper pass
            </Gild>
          </p>
          <span className="text-[10px] font-medium uppercase tracking-[0.2em] text-neutral-600">
            Custom colors
          </span>
        </div>
      </div>
    </div>
  );
}
```

## Accessibility & performance

Honors `prefers-reduced-motion` with a designed static frame or fade (never a blank box) and passes `className` through.

## Source (`gild.tsx`)

```tsx
"use client";

import * as React from "react";

import { cn } from "@/lib/utils";
import { useReducedMotion } from "@/hooks/use-reduced-motion";

export interface GildColors {
  /** Resting metal tone the sweep travels across. @default warm neutral-bronze */
  base?: string;
  /** White core of the sweep. @default white */
  core?: string;
  /** Inner edge of the sweep. @default champagne gold */
  amber?: string;
  /** Outer edge of the sweep. @default deep champagne */
  ember?: string;
}

export interface GildProps extends React.ComponentPropsWithoutRef<"span"> {
  /** Element tag rendered. @default "span" */
  as?: "span" | "div" | "p" | "h1" | "h2" | "h3";
  /** Gradient stops for the base tone and sweep core/edges. */
  colors?: GildColors;
  /** Seconds between sweeps. @default 4.5 */
  interval?: number;
  /** Sweep angle in degrees. @default 100 */
  angle?: number;
  /** Only sweep while hovered, instead of continuously on an interval. @default false */
  hoverOnly?: boolean;
  /** Freeze the sweep at its current frame. @default false */
  paused?: boolean;
}

const DEFAULT_COLORS: Required<GildColors> = {
  base: "#9c8b6e",
  core: "#ffffff",
  amber: "#e8d5a3",
  ember: "#c9ae7c",
};

/**
 * Gild — a narrow white light band, edged in refined champagne gold, sweeps
 * across a brushed neutral-bronze text fill on a deliberate slow interval —
 * never a constant conveyor shimmer. Pure CSS, driven by an animated
 * `@property` so the sweep interpolates smoothly inside the gradient stops.
 * Freezes at a static mid-sweep frame under reduced motion.
 */
export function Gild({
  as = "span",
  colors,
  interval = 4.5,
  angle = 100,
  hoverOnly = false,
  paused = false,
  className,
  style,
  children,
  ...props
}: GildProps) {
  const reducedMotion = useReducedMotion();
  const c = { ...DEFAULT_COLORS, ...colors };
  const Tag = as;

  const gradient = `linear-gradient(${angle}deg,
    ${c.base} 0%,
    ${c.base} calc(var(--gild-shine, 45%) - 22%),
    ${c.amber} calc(var(--gild-shine, 45%) - 8%),
    ${c.core} var(--gild-shine, 45%),
    ${c.amber} calc(var(--gild-shine, 45%) + 8%),
    ${c.ember} calc(var(--gild-shine, 45%) + 16%),
    ${c.base} calc(var(--gild-shine, 45%) + 30%),
    ${c.base} 100%)`;

  const forcePaused = paused || reducedMotion;

  return (
    <Tag
      data-crucible="gild"
      data-hover-only={hoverOnly ? "" : undefined}
      className={cn("gild-text inline-block bg-clip-text text-transparent", className)}
      style={
        {
          backgroundImage: gradient,
          backgroundSize: "220% 220%",
          // Per-instance duration: the <style> rule below is shared by every
          // Gild on the page, so the interval must ride a custom property.
          "--gild-interval": `${Math.max(interval, 0.1)}s`,
          ...(forcePaused ? { "--gild-play": "paused" } : {}),
          ...(reducedMotion ? { "--gild-shine": "45%" } : {}),
          ...style,
        } as React.CSSProperties
      }
      {...props}
    >
      <style>{`
        /* Rest at -35% so every sweep stop (widest: shine + 30%) sits below 0%
           and the resting fill is pure base — no stuck ember glyph. */
        @property --gild-shine {
          syntax: '<percentage>';
          inherits: true;
          initial-value: -35%;
        }
        @keyframes crucible-gild-sweep {
          0% { --gild-shine: -35%; }
          30% { --gild-shine: 120%; }
          100% { --gild-shine: 120%; }
        }
        [data-crucible="gild"] {
          animation: crucible-gild-sweep var(--gild-interval, 4.5s) ease-in-out infinite;
          animation-play-state: var(--gild-play, running);
        }
        [data-crucible="gild"][data-hover-only] {
          animation-play-state: var(--gild-play, paused);
        }
        [data-crucible="gild"][data-hover-only]:hover {
          animation-play-state: var(--gild-play, running);
        }
        @media (prefers-reduced-motion: reduce) {
          [data-crucible="gild"] {
            animation: none;
            --gild-shine: 45%;
          }
        }
      `}</style>
      {children}
    </Tag>
  );
}
```
