E-Commerce
Customer Segments Card - Audience Analysis
Monitor customer segmentation and demographic analysis. Track customer groups and tailor marketing strategies by segment.
Customer Segments Card
The Customer Segments Card Analyze customer segmentation and behavior patterns.
Preview
Installation
ash npx shadcn@latest add https://vectormotion.vercel.app/registry/customer-segments-card.json
Customer Segments Card
'use client';import React from "react";import { Users, PieChart } 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 Segment { name: string; count: number; revenue: number; color: string;}interface CustomerSegmentsCardProps { className?: string; title?: string; description?: string; segments?: Segment[];}const DEFAULT_TITLE = "Customer Segments";const DEFAULT_DESCRIPTION = "Segmentation Analysis";const DEFAULT_SEGMENTS: Segment[] = [ { name: "High Value", count: 450, revenue: 125000, color: "bg-purple-500" }, { name: "Regular", count: 1200, revenue: 89000, color: "bg-blue-500" }, { name: "Occasional", count: 800, revenue: 34000, color: "bg-emerald-500" }, { name: "New", count: 550, revenue: 12000, color: "bg-amber-500" },];export const CustomerSegmentsCard: React.FC<CustomerSegmentsCardProps> = ({ className = "", title = DEFAULT_TITLE, description = DEFAULT_DESCRIPTION, segments = DEFAULT_SEGMENTS,}) => { const isInteractive = true; const index = 28; const totalCustomers = segments.reduce((sum, s) => sum + s.count, 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"> <PieChart className="h-5 w-5 text-indigo-500" /> </div> </div> <div className="relative z-10 flex-1"> <div className="text-2xl font-bold text-foreground mb-1"> {totalCustomers.toLocaleString()} </div> <p className="text-sm text-muted-foreground mb-4">Total customers</p> <div className="space-y-3"> {segments.map((segment, idx) => { const percentage = Math.round( (segment.count / totalCustomers) * 100, ); const avgValue = Math.round(segment.revenue / segment.count); return ( <motion.div key={idx} initial={{ opacity: 0, y: 5 }} animate={{ opacity: 1, y: 0 }} transition={{ duration: 0.4, delay: idx * 0.1 }} className="bg-muted rounded-lg p-3" > <div className="flex justify-between items-center mb-2"> <div className="flex items-center gap-2"> <div className={`w-3 h-3 rounded-full ${segment.color}`} /> <span className="text-sm font-medium text-foreground"> {segment.name} </span> </div> <span className="text-sm font-bold text-foreground"> {segment.count} </span> </div> <div className="flex justify-between text-xs text-muted-foreground"> <span>{percentage}% of total</span> <span>${avgValue} avg value</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