Free · MIT

Glass Card

A frosted card that tilts toward the cursor, with a moving highlight.

Spring-smoothed tilt from the pointer, a highlight that follows it, and a frosted edge. Put your own content inside as children.

The code

The whole file is below. Install the packages it imports, add the file to your project and import it.

GlassCard.tsx
"use client";

/**
 * Glass Card — a frosted panel that tilts toward the cursor.
 *
 * Self-contained: framer-motion. Put anything inside as children.
 *
 *   <GlassCard accent="#f5cb73" tilt={12}>…</GlassCard>
 */
import { motion, useMotionTemplate, useMotionValue, useSpring } from "framer-motion";
import type { PointerEvent, ReactNode } from "react";

export type GlassCardProps = {
  accent?: string;
  /** Maximum tilt in degrees. */
  tilt?: number;
  children?: ReactNode;
  className?: string;
};

export function GlassCard({ accent = "#f5cb73", tilt = 12, children, className = "" }: GlassCardProps) {
  const px = useMotionValue(0.5);
  const py = useMotionValue(0.5);
  const rx = useSpring(useMotionValue(0), { stiffness: 160, damping: 18 });
  const ry = useSpring(useMotionValue(0), { stiffness: 160, damping: 18 });
  const glareX = useSpring(px, { stiffness: 120, damping: 20 });
  const glareY = useSpring(py, { stiffness: 120, damping: 20 });

  const glare = useMotionTemplate`radial-gradient(420px circle at calc(${glareX} * 100%) calc(${glareY} * 100%), ${accent}2e, transparent 60%)`;

  function move(event: PointerEvent<HTMLDivElement>) {
    const rect = event.currentTarget.getBoundingClientRect();
    const x = (event.clientX - rect.left) / rect.width;
    const y = (event.clientY - rect.top) / rect.height;
    px.set(x);
    py.set(y);
    ry.set((x - 0.5) * tilt * 2);
    rx.set((0.5 - y) * tilt * 2);
  }

  function leave() {
    px.set(0.5);
    py.set(0.5);
    rx.set(0);
    ry.set(0);
  }

  return (
    <div className={className} style={{ perspective: 1200, width: "100%" }}>
      <motion.div
        onPointerMove={move}
        onPointerLeave={leave}
        style={{
          rotateX: rx,
          rotateY: ry,
          transformStyle: "preserve-3d",
          position: "relative",
          borderRadius: 18,
          padding: 28,
          minHeight: 220,
          color: "#f7efe3",
          background: "linear-gradient(160deg, rgba(255,255,255,0.10), rgba(255,255,255,0.03))",
          border: "1px solid rgba(255,255,255,0.16)",
          boxShadow: "0 30px 60px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.2)",
          backdropFilter: "blur(18px)",
          WebkitBackdropFilter: "blur(18px)",
          overflow: "hidden",
        }}
      >
        <motion.div aria-hidden style={{ position: "absolute", inset: 0, background: glare, pointerEvents: "none" }} />
        <div style={{ position: "relative", transform: "translateZ(30px)" }}>
          {children ?? (
            <>
              <p style={{ margin: 0, fontSize: 11, letterSpacing: "0.2em", textTransform: "uppercase", color: accent }}>
                Glass card
              </p>
              <p style={{ margin: "14px 0 0", fontSize: 28, lineHeight: 1.1, letterSpacing: "-0.03em", fontWeight: 600 }}>
                Frosted, tilting,
                <br />
                catching the light.
              </p>
              <p style={{ margin: "14px 0 0", fontSize: 14, lineHeight: 1.6, color: "rgba(247,239,227,0.7)" }}>
                Move the cursor. Put your own content here.
              </p>
            </>
          )}
        </div>
      </motion.div>
    </div>
  );
}

export default GlassCard;

Inside

  • Spring-smoothed tilt from pointer position
  • Highlight that tracks the pointer
  • Frosted glass with a hairline edge
  • Takes children

Install

npm install framer-motion

One file.

Kind
Cards
Licence
MIT
Runs on
React 19
Price
Free

More elements

3D objects
Pro
Chrome Blob: open the element page

Chrome Blob

A metallic sphere that distorts as it turns, with studio reflections.

Price
USD 10, all access
Built with
React Three Fiber

FAQ

What you get, what it runs on, what it costs to run and what the licence allows.

01

What do I get?

One React component file per element, plus any shader or asset files it needs. Members of a series also get the small engine file they share. Free elements are copied from the page. Pro elements are a download after one payment of USD 10, which unlocks all of them. Each element imports only public packages, which are listed on its page.

02

What does it run on?

React 19. The 3D and shader elements use three.js through React Three Fiber. The 2D ones use Framer Motion or plain CSS and canvas. They work in Next.js, Vite, Remix and any other React setup. Framer and Webflow users can embed an element as a code component.

03

Can I change the colours and speed?

Yes. Every element exposes its look as props, the same controls shown on its page. Anything beyond the props is yours to edit in the file.

04

Can I use these in a deck, a magazine or a film?

Yes. Every element page has a Save frame button that downloads the current frame as a PNG at the size shown. Make the browser window large for a print-size still. For motion, record the page or ask us for a rendered clip. The licence covers web, print, decks and video, for your own work and your clients' work.

05

How heavy is it?

The 3D elements mount when they scroll into view and unmount when they leave, so an element off screen costs nothing. The shader backgrounds cost a fraction of a video background. The 2D elements are a few kilobytes.

06

What is the licence?

Free elements are MIT. Use them anywhere, including client work. Pro elements are licensed to you for unlimited projects of your own and your clients'. You may not resell or redistribute the source itself.

07

Can you make one for us?

Yes. A custom element, such as your product in 3D or a branded shader, is a small project quoted up front. All-access members are asked first about what we build next.