{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "cards-slider-shadcnui", "type": "registry:component", "title": "Cards Slider", "description": "Liquid smooth draggable cards slider with shadcn/ui styling and framer-motion animations", "dependencies": [ "framer-motion", "react" ], "files": [ { "path": "@uitripled/react-shadcn/src/components/components/sliders/cards-slider.tsx", "content": "\"use client\";\n\nimport { Avatar, AvatarFallback, AvatarImage } from \"@/components/ui/avatar\";\nimport { Badge } from \"@/components/ui/badge\";\nimport { Card } from \"@/components/ui/card\";\nimport { animate, motion, useMotionValue } from \"framer-motion\";\nimport { ChevronLeft, ChevronRight, Clock } from \"lucide-react\";\nimport { useEffect, useRef, useState } from \"react\";\n\ninterface CardData {\n id: number;\n title: string;\n description: string;\n category: string;\n image: string;\n author: {\n name: string;\n avatar: string;\n };\n date: string;\n readTime: string;\n}\n\nconst cards: CardData[] = [\n {\n id: 1,\n title: \"Liquid Motion\",\n description:\n \"Experience the fluid dynamics of modern web interactions with physics-based animations.\",\n category: \"Animation\",\n image:\n \"https://images.unsplash.com/photo-1618005182384-a83a8bd57fbe?w=800&q=80\",\n author: { name: \"Alex Rivera\", avatar: \"https://github.com/shadcn.png\" },\n date: \"Dec 12, 2024\",\n readTime: \"5 min read\",\n },\n {\n id: 2,\n title: \"Glassmorphism\",\n description:\n \"Blur the lines between layers with advanced backdrop filters and transparency effects.\",\n category: \"Design\",\n image:\n \"https://images.unsplash.com/photo-1618221195710-dd6b41faaea6?w=800&q=80\",\n author: { name: \"Sarah Chen\", avatar: \"https://github.com/shadcn.png\" },\n date: \"Dec 10, 2024\",\n readTime: \"4 min read\",\n },\n {\n id: 3,\n title: \"Dark Mode\",\n description:\n \"Easy on the eyes, elegant in appearance. A seamless transition to the dark side.\",\n category: \"Theme\",\n image:\n \"https://images.unsplash.com/photo-1618005198919-d3d4b5a92ead?w=800&q=80\",\n author: { name: \"Mike Johnson\", avatar: \"https://github.com/shadcn.png\" },\n date: \"Dec 8, 2024\",\n readTime: \"6 min read\",\n },\n {\n id: 4,\n title: \"Micro-Interactions\",\n description:\n \"Delightful details that make the difference between good and great user experience.\",\n category: \"UX\",\n image:\n \"https://images.unsplash.com/photo-1620641788421-7a1c342ea42e?w=800&q=80\",\n author: { name: \"Emily Davis\", avatar: \"https://github.com/shadcn.png\" },\n date: \"Dec 5, 2024\",\n readTime: \"3 min read\",\n },\n {\n id: 5,\n title: \"Responsive Layouts\",\n description:\n \"Fluid grids that adapt to any screen size, ensuring your content looks perfect everywhere.\",\n category: \"Layout\",\n image:\n \"https://images.unsplash.com/photo-1618005182384-a83a8bd57fbe?w=800&q=80\",\n author: { name: \"David Kim\", avatar: \"https://github.com/shadcn.png\" },\n date: \"Dec 3, 2024\",\n readTime: \"7 min read\",\n },\n];\n\nexport function CardsSlider() {\n const containerRef = useRef(null);\n const [width, setWidth] = useState(0);\n const x = useMotionValue(0);\n const [currentIndex, setCurrentIndex] = useState(0);\n\n useEffect(() => {\n if (containerRef.current) {\n setWidth(\n containerRef.current.scrollWidth - containerRef.current.offsetWidth\n );\n }\n }, []);\n\n const CARD_WIDTH = 350; // Approximate width + gap\n const GAP = 24;\n\n const scrollTo = (direction: \"left\" | \"right\") => {\n const currentX = x.get();\n const containerWidth = containerRef.current?.offsetWidth || 0;\n const scrollAmount = containerWidth * 0.8; // Scroll 80% of container width\n\n let newX =\n direction === \"left\" ? currentX + scrollAmount : currentX - scrollAmount;\n\n // Clamp values\n newX = Math.max(Math.min(newX, 0), -width);\n\n animate(x, newX, {\n type: \"spring\",\n stiffness: 300,\n damping: 30,\n mass: 1,\n });\n };\n\n return (\n
\n {/* Navigation Arrows */}\n
\n scrollTo(\"left\")}\n className=\"h-12 w-12 rounded-full bg-background/80 backdrop-blur-md border border-border/50 shadow-lg flex items-center justify-center hover:bg-background hover:scale-110 transition-all active:scale-95\"\n aria-label=\"Scroll left\"\n >\n \n \n
\n
\n scrollTo(\"right\")}\n className=\"h-12 w-12 rounded-full bg-background/80 backdrop-blur-md border border-border/50 shadow-lg flex items-center justify-center hover:bg-background hover:scale-110 transition-all active:scale-95\"\n aria-label=\"Scroll right\"\n >\n \n \n
\n\n \n \n {cards.map((card) => (\n \n \n {/* Image Section */}\n
\n \n
\n\n
\n \n {card.category}\n \n
\n\n {/* Hover Overlay Action */}\n
\n \n View Details\n \n
\n
\n\n {/* Content Section */}\n
\n
\n

\n {card.title}\n

\n

\n {card.description}\n

\n
\n\n
\n
\n \n \n {card.author.name[0]}\n \n
\n \n {card.author.name}\n \n \n {card.date}\n \n
\n
\n
\n \n {card.readTime}\n
\n
\n
\n \n \n ))}\n \n \n
\n );\n}\n", "type": "registry:component", "target": "components/uitripled/cards-slider-shadcnui.tsx" } ] }