E-Commerce
Product Views Card - Page Analytics
Monitor product page views and visitor engagement. Track product interest and browsing behavior.
Product Views Card
The Product Views Card Track product page views and engagement.
Preview
Installation
ash npx shadcn@latest add https://vectormotion.vercel.app/registry/product-views-card.json
Product Views Card
'use client';import React from "react";import { Eye, TrendingUp } from "lucide-react";import { motion } from "motion/react";import { clsx, type ClassValue } from "clsx";import { twMerge } from "tailwind-merge";function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs));}interface Product { name: string; views: number; addToCart: number; rate: number; [key: string]: any;}interface ProductViewsCardProps { className?: string; title?: string; description?: string; products?: Product[];}const DEFAULT_TITLE = "Product Views";const DEFAULT_DESCRIPTION = "Top Products";const DEFAULT_PRODUCTS: Product[] = [ { name: "Wireless Earbuds Pro", views: 12500, addToCart: 1875, rate: 15 }, { name: "Smart Watch Ultra", views: 9800, addToCart: 1470, rate: 15 }, { name: "Phone Case Premium", views: 7200, addToCart: 864, rate: 12 },];export const ProductViewsCard: React.FC<ProductViewsCardProps> = ({ className = "", title = DEFAULT_TITLE, description = DEFAULT_DESCRIPTION, products = DEFAULT_PRODUCTS,}) => { const isInteractive = true; const index = 45; const totalViews = products.reduce((sum, p) => sum + p.views, 0); return ( <motion.div layoutId={isInteractive ? `card-${index}-${title}` : undefined} transition={{ duration: 0.4, ease: "easeOut" }} className={cn( "relative overflow-hidden rounded-xl border border-border bg-card text-card-foreground p-6 shadow-sm transition-all flex flex-col group", isInteractive ? "cursor-pointer hover:border-zinc-300 dark:hover:border-zinc-700" : "", className, )} > <div className="mb-4 flex items-start justify-between relative z-10"> <div> <h3 className="font-semibold text-lg tracking-tight text-foreground"> {title} </h3> {description && ( <p className="text-sm text-muted-foreground mt-1">{description}</p> )} </div> <div className="rounded-full bg-zinc-100 dark:bg-zinc-800 p-2 text-foreground flex items-center justify-center"> <Eye className="h-5 w-5 text-blue-500" /> </div> </div> <div className="relative z-10 flex-1"> <div className="flex items-baseline gap-2 mb-2"> <div className="text-3xl font-bold text-foreground"> {(totalViews / 1000).toFixed(1)}K </div> <TrendingUp className="h-5 w-5 text-emerald-500" /> </div> <p className="text-sm text-muted-foreground mb-4"> Total product views </p> <div className="space-y-3"> {products.map((product, idx) => ( <motion.div key={idx} initial={{ opacity: 0, x: -10 }} animate={{ opacity: 1, x: 0 }} transition={{ duration: 0.4, delay: idx * 0.1 }} className="bg-muted rounded-lg p-3" > <div className="flex justify-between items-start mb-2"> <span className="text-sm font-medium text-foreground"> {product.name} </span> <span className="text-sm font-bold text-blue-500"> {(product.views / 1000).toFixed(1)}K </span> </div> <div className="flex justify-between text-xs text-muted-foreground"> <span>{product.addToCart} added to cart</span> <span className="text-emerald-500 font-medium"> {product.rate}% conversion </span> </div> </motion.div> ))} </div> </div> </motion.div> );};Usage
This component is a data-rich dashboard card displaying e-commerce metrics with animated visualizations and dark mode support. Perfect for dashboards, landing pages, and analytics interfaces.
Prop
Type