Card Cue Free React component
A compact card that springs open to reveal a hidden form underneath, then tucks it away again, all in one smooth layout animation.
Original component by Watermelon UI · MIT licence
Get the code
npx shadcn@latest add https://registry.watermelon.sh/r/card-cue.jsonInstalls from the Watermelon UI registry through the shadcn CLI. Needs Tailwind CSS and the motion package, which the command adds for you.
import CardCue from '../card-cue';
function CardCueDemoOriginal() {
return <CardCue />;
}
export default CardCueDemoOriginal;
// card-cue, from Watermelon UI: https://ui.watermelon.sh/animated-components/card-cue
// MIT License. Copyright (c) 2025-present Watermelon Contributors.
'use client';
import { useRef, useState } from 'react';
import { motion } from 'framer-motion';
import { ChevronLeft, X } from 'lucide-react';
export default function CardCue() {
const [cardNumber, setCardNumber] = useState('');
const [expiration, setExpiration] = useState('');
const [cvv, setCvv] = useState('');
const [isErrorAnimation, setIsErrorAnimation] = useState(false);
const [cardNumberFocused, setCardNumberFocused] = useState(false);
const cardNumberRef = useRef<HTMLInputElement>(null);
const handleAddCard = () => {
if (!cardNumber.trim()) {
setIsErrorAnimation(true);
setCardNumberFocused(true);
cardNumberRef.current?.focus();
setTimeout(() => setIsErrorAnimation(false), 200);
} else {
console.log('Card added', { cardNumber, expiration, cvv });
}
};
return (
<div className="flex h-screen w-full items-center justify-center ">
<div className="mx-auto flex w-full max-w-sm flex-col gap-6 rounded-3xl bg-white p-6 dark:bg-zinc-950/50 border border-border">
<div className="flex items-center justify-between">
<button className="flex h-10 w-10 items-center justify-center rounded-full bg-zinc-100 text-zinc-600 transition-colors hover:bg-zinc-200 focus:outline-none dark:bg-zinc-900 dark:text-zinc-400 dark:hover:bg-zinc-800">
<ChevronLeft className="h-5 w-5" />
</button>
<h2 className="text-lg font-semibold text-zinc-900 dark:text-zinc-100">
Add Card
</h2>
<button className="flex h-10 w-10 items-center justify-center rounded-full bg-zinc-100 text-zinc-600 transition-colors hover:bg-zinc-200 focus:outline-none dark:bg-zinc-900 dark:text-zinc-400 dark:hover:bg-zinc-800">
<X className="h-5 w-5" />
</button>
</div>
<div className="flex flex-col gap-4">
<motion.div
animate={
isErrorAnimation
? {
scale: 1.1,
}
: { scale: 1 }
}
transition={{ type: 'spring', bounce: 0.1, duration: 0.4 }}
className="rounded-2xl"
>
<input
ref={cardNumberRef}
type="text"
placeholder="Card Number"
value={cardNumber}
onChange={(e) => setCardNumber(e.target.value)}
onFocus={() => setCardNumberFocused(true)}
onBlur={() => setCardNumberFocused(false)}
className={`h-14 w-full rounded-2xl bg-zinc-100 px-4 text-base text-zinc-900 ring-3 transition-all outline-none placeholder:text-zinc-400 focus:bg-white dark:bg-zinc-900 dark:text-zinc-100 dark:placeholder:text-zinc-500 dark:focus:bg-zinc-950 ${
cardNumberFocused
? 'ring-zinc-900 dark:ring-zinc-100'
: 'ring-transparent'
}`}
/>
</motion.div>
<div className="flex gap-4">
<input
type="text"
placeholder="Expiration"
value={expiration}
onChange={(e) => setExpiration(e.target.value)}
className="h-14 w-full rounded-2xl bg-zinc-100 px-4 text-base text-zinc-900 ring-3 ring-transparent transition-all outline-none placeholder:text-zinc-400 focus:bg-white focus:ring-zinc-900 dark:bg-zinc-900 dark:text-zinc-100 dark:placeholder:text-zinc-500 dark:focus:bg-zinc-950 dark:focus:ring-zinc-100"
/>
<input
type="text"
placeholder="CVV"
value={cvv}
onChange={(e) => setCvv(e.target.value)}
className="h-14 w-full rounded-2xl bg-zinc-100 px-4 text-base text-zinc-900 ring-3 ring-transparent transition-all outline-none placeholder:text-zinc-400 focus:bg-white focus:ring-zinc-900 dark:bg-zinc-900 dark:text-zinc-100 dark:placeholder:text-zinc-500 dark:focus:bg-zinc-950 dark:focus:ring-zinc-100"
/>
</div>
</div>
<motion.button
whileTap={{ scale: 0.97 }}
onClick={handleAddCard}
className="mt-2 w-full rounded-2xl bg-zinc-900 py-4 text-base font-medium text-white transition-colors hover:bg-zinc-800 focus:outline-none dark:bg-zinc-100 dark:text-zinc-900 dark:hover:bg-zinc-200"
>
Add Card
</motion.button>
</div>
</div>
);
}
Paste this into Claude, ChatGPT, Cursor, Lovable or v0 to build it from scratch.
Build a React component called "Card Cue" with Tailwind CSS and Motion (motion/react). A compact card that springs open to reveal a hidden form underneath, then tucks it away again, all in one smooth layout animation. Use spring transitions, keep it accessible with keyboard focus and aria labels, respect prefers-reduced-motion, and make it work on touch screens. Export it as a single .tsx file with sensible default props so it renders a complete demo on its own.How the card cue works
A compact card that springs open to reveal a hidden form underneath, then tucks it away again, all in one smooth layout animation. The component is a single TypeScript file built with React, Tailwind CSS and Motion, so the animation runs on springs and shared layouts instead of hand-written keyframes.
It comes from Watermelon UI, an open-source component library released under the MIT licence. Install it with the shadcn command above, or copy the source from the code tab into your project.
Frequently asked questions
Want motion like this on your website?
We design and build custom websites with motion, 3D and SEO built in. Websites from $500.