A sliding row of project cards with arrows and dots. Show one, two or three at a time; visitors drag it or tap to move along.
How to use
Make two files in your project's components folder: work-carousel.tsx and work-carousel.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 { Children, createContext, type ReactNode, useContext, useEffect, useMemo, useRef, useState } from "react";
import styles from "./work-carousel.module.css";
/** A spring for each step: stiffness, damping and mass, as in most motion tools. */
export type CarouselTransition = { stiffness?: number; damping?: number; mass?: number };
/** A spring's motion written as a CSS easing, plus how long it takes to settle, in ms. */
function springEasing(stiffness: number, damping: number, mass: number) {
const w0 = Math.sqrt(stiffness / mass);
const zeta = damping / (2 * Math.sqrt(stiffness * mass));
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 { Children, createContext, type ReactNode, useContext, useEffect, useMemo, useRef, useState } from "react";
import styles from "./work-carousel.module.css";
/** A spring for each step: stiffness, damping and mass, as in most motion tools. */
export type CarouselTransition = { stiffness?: number; damping?: number; mass?: number };
/** A spring's motion written as a CSS easing, plus how long it takes to settle, in ms. */
function springEasing(stiffness: number, damping: number, mass: number) {
const w0 = Math.sqrt(stiffness / mass);
const zeta = damping / (2 * Math.sqrt(stiffness * mass));
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.