Wrap a project card and it tilts in 3D as the cursor moves over it, then settles flat. A light touch for a grid of work.
How to use
Make two files in your project's components folder: tilt-card.tsx and tilt-card.module.css.
Paste the code into each one, keeping the licence note at the top of the component.
It needs nothing beyond React. Your project needs CSS Modules, which Next.js and Vite already have.
Import it where you want it, then change the words, colours and sizes to yours.
The code
"use client";
import React, { useEffect, useRef } from "react";
import styles from "./tilt-card.module.css";
/** Stiffness, damping and mass, as in most motion tools. */
export type SpringOptions = { stiffness?: number; damping?: number; mass?: number };
/** Moves x and y towards their targets like a spring, one frame at a time. */
function createSpring(options: SpringOptions, write: (x: number, y: number) => void) {
const k = options.stiffness ?? 100;
const c = options.damping ?? 10;
This comes with paid plans
The code for every component comes with paid plans, along with the rest of the AI toolkit. The first component under each heading is free.
"use client";
import React, { useEffect, useRef } from "react";
import styles from "./tilt-card.module.css";
/** Stiffness, damping and mass, as in most motion tools. */
export type SpringOptions = { stiffness?: number; damping?: number; mass?: number };
/** Moves x and y towards their targets like a spring, one frame at a time. */
function createSpring(options: SpringOptions, write: (x: number, y: number) => void) {
const k = options.stiffness ?? 100;
const c = options.damping ?? 10;
This comes with paid plans
The code for every component comes with paid plans, along with the rest of the AI toolkit. The first component under each heading is free.