E-Commerce
Customer Retention Card - Loyalty Metrics
Track customer retention rates and repeat purchase behavior. Monitor churn and loyalty program effectiveness.
Customer Retention Card
The Customer Retention Card Monitor customer retention rates and loyalty.
Preview
Installation
ash npx shadcn@latest add https://vectormotion.vercel.app/registry/customer-retention-card.json
Customer Retention Card
'use client';import React from "react";import { Heart, 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 Cohort { month: string; retention: number; customers: number; [key: string]: any;}interface CustomerRetentionCardProps { className?: string; title?: string; description?: string; retentionRate?: string; retentionRateChange?: number; cohorts?: Cohort[];}const DEFAULT_TITLE = "Customer Retention";const DEFAULT_DESCRIPTION = "Retention Tracking";const DEFAULT_RETENTION_RATE = "87%";const DEFAULT_RETENTION_RATE_CHANGE = 3.2;const DEFAULT_COHORTS: Cohort[] = [ { month: "Jan", retention: 85, customers: 450 }, { month: "Feb", retention: 82, customers: 520 }, { month: "Mar", retention: 88, customers: 480 }, { month: "Apr", retention: 91, customers: 550 },];export const CustomerRetentionCard: React.FC<CustomerRetentionCardProps> = ({ className = "", title = DEFAULT_TITLE, description = DEFAULT_DESCRIPTION, retentionRate = DEFAULT_RETENTION_RATE, retentionRateChange = DEFAULT_RETENTION_RATE_CHANGE, cohorts = DEFAULT_COHORTS,}) => { const isInteractive = true; const index = 24; 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"> <Heart className="h-5 w-5 text-red-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"> {retentionRate} </div> <div className="flex items-center gap-1 text-sm"> <TrendingUp className="h-4 w-4 text-emerald-500" /> <span className="text-emerald-500 font-medium"> +{retentionRateChange}% </span> </div> </div> <p className="text-sm text-muted-foreground mb-4"> Average retention rate </p> <div className="space-y-3"> {cohorts.map((cohort, idx) => ( <div key={idx}> <div className="flex justify-between items-center mb-1"> <span className="text-sm text-foreground"> {cohort.month} Cohort </span> <div className="flex items-center gap-2"> <span className="text-xs text-muted-foreground"> {cohort.customers} users </span> <span className="text-sm font-bold text-foreground"> {cohort.retention}% </span> </div> </div> <div className="flex items-center gap-2"> <div className="flex-1 bg-zinc-100 dark:bg-zinc-800 rounded-full h-2 overflow-hidden"> <motion.div initial={{ width: 0 }} animate={{ width: `${cohort.retention}%` }} transition={{ duration: 1, delay: idx * 0.1 }} className={`h-full rounded-full ${cohort.retention >= 90 ? "bg-emerald-500" : cohort.retention >= 80 ? "bg-blue-500" : "bg-amber-500" }`} /> </div> </div> </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