E-Commerce
Sales by Region Card - Geographic Analytics
Analyze sales performance by geographic region. Identify regional trends and market opportunities.
Sales by Region Card
The Sales by Region Card Track geographic sales distribution and regional growth.
Preview
Installation
ash npx shadcn@latest add https://vectormotion.vercel.app/registry/sales-by-region-card.json
Sales by Region Card
'use client';import React from "react";import { MapPin, DollarSign } 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 Region { name: string; sales: number; percentage: number; growth: string; color: string; [key: string]: any;}interface SalesByRegionCardProps { className?: string; title?: string; description?: string; totalSales?: string; regions?: Region[];}const DEFAULT_TITLE = "Sales by Region";const DEFAULT_DESCRIPTION = "Geographic Distribution";const DEFAULT_TOTAL_SALES = "$100K";const DEFAULT_REGIONS: Region[] = [ { name: "North America", sales: 45000, percentage: 45, growth: "+12%", color: "bg-blue-500", }, { name: "Europe", sales: 30000, percentage: 30, growth: "+8%", color: "bg-purple-500", }, { name: "Asia Pacific", sales: 20000, percentage: 20, growth: "+18%", color: "bg-emerald-500", }, { name: "Other", sales: 5000, percentage: 5, growth: "+5%", color: "bg-zinc-400", },];export const SalesByRegionCard: React.FC<SalesByRegionCardProps> = ({ className = "", title = DEFAULT_TITLE, description = DEFAULT_DESCRIPTION, totalSales = DEFAULT_TOTAL_SALES, regions = DEFAULT_REGIONS,}) => { const isInteractive = true; const index = 8; 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"> <MapPin className="h-5 w-5 text-blue-500" /> </div> </div> <div className="relative z-10 flex-1"> <div className="text-2xl font-bold text-foreground mb-4"> {totalSales} </div> <div className="space-y-3"> {regions.map((region, idx) => ( <div key={idx}> <div className="flex justify-between items-center mb-1"> <span className="text-sm text-foreground">{region.name}</span> <div className="flex items-center gap-2"> <span className="text-xs text-emerald-500 font-medium"> {region.growth} </span> <span className="text-sm font-bold text-foreground"> ${region.sales.toLocaleString()} </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: `${region.percentage}%` }} transition={{ duration: 1, delay: idx * 0.1 }} className={`h-full ${region.color} rounded-full`} /> </div> <span className="text-xs text-muted-foreground w-8 text-right"> {region.percentage}% </span> </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