Card Flip
scrollxui/card-flipFreeComponent
Renders a card component with flip animation, supporting front/back content.
Live preview
live · rendered by the registry
Rendered by scrollxui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://scrollxui.dev/registry/card-flip.jsonSource
1'use client';2import React, { useState } from 'react';3import { motion } from 'motion/react';4import { Info, X } from 'lucide-react';5import { cn } from '@/lib/utils';67function CardFlip({8 className,9 children,10 ...props11}: React.ComponentProps<'div'> & {12 children: [React.ReactNode, React.ReactNode];13}) {14 const [isFlipped, setIsFlipped] = useState(false);15 const [front, back] = React.Children.toArray(children);1617 return (18 <div19 className={cn('relative w-full', className)}20 style={{ perspective: '1000px' }}21 {...props}22 >23 <motion.div24 className='relative w-full'25 initial={false}26 animate={{ rotateY: isFlipped ? -180 : 0 }}27 transition={{ duration: 0.6, ease: [0.4, 0, 0.2, 1] }}28 style={{ transformStyle: 'preserve-3d' }}29 >30 <div31 className='w-full'32 style={{33 backfaceVisibility: 'hidden',34 WebkitBackfaceVisibility: 'hidden',35 transformStyle: 'preserve-3d',36 }}37 >38 <div className='relative w-full'>39 <button40 onClick={() => setIsFlipped(true)}41 className='absolute top-4 right-4 p-2 rounded-full hover:bg-muted transition-colors z-10'42 aria-label='Show info'43 style={{44 opacity: isFlipped ? 0 : 1,45 pointerEvents: isFlipped ? 'none' : 'auto',46 transition: 'opacity 0.3s',47 }}48 >49 <Info className='w-5 h-5 text-muted-foreground' />50 </button>51 {front}52 </div>53 </div>5455 <div56 className='absolute inset-0 w-full'57 style={{58 backfaceVisibility: 'hidden',59 WebkitBackfaceVisibility: 'hidden',60 transform: 'rotateY(-180deg)',61 transformStyle: 'preserve-3d',62 }}63 >64 <div className='relative w-full h-full'>65 <button66 onClick={() => setIsFlipped(false)}67 className='absolute top-4 right-4 p-2 rounded-full hover:bg-muted transition-colors z-10'68 aria-label='Close'69 style={{70 opacity: isFlipped ? 1 : 0,71 pointerEvents: isFlipped ? 'auto' : 'none',72 transition: 'opacity 0.3s',73 }}74 >75 <X className='w-5 h-5 text-muted-foreground' />76 </button>77 {back}78 </div>79 </div>80// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from scrollxui
All 180 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | scrollxui | Components | Free | 4 deps | |
| Alert Dialogalert-dialog | scrollxui | Components | Free | 7 deps | |
| Animated Buttonanimated-button | scrollxui | Components | Free | 4 deps | |
| Animated Tabsanimated-tabs | scrollxui | Components | Free | 1 dep | |
| Animated Testimonialsanimated-testimonials | scrollxui | Components | Free | 2 deps | |
| Animated TextGenerateanimated-textgenerate | scrollxui | Components | Free | 3 deps | |
| Announcementannouncement | scrollxui | Components | Free | 5 deps | |
| Aspect Ratioaspect-ratio | scrollxui | Components | Free | 1 dep |
