Education
Library Stats Card - Library Analytics
Monitor library usage statistics and resource circulation. Track popular materials and library engagement metrics.
Library Stats Card
The Library Stats Card displays library circulation statistics including books checked out and overdue items.
Preview
Installation
npx shadcn@latest add https://vectormotion.vercel.app/registry/library-stats-card.jsonLibrary Stats Card
'use client'import React from 'react';import { BookOpen } from 'lucide-react';import { motion } from 'motion/react';import { clsx, type ClassValue } from "clsx";import { twMerge } from "tailwind-merge";import { ResponsiveContainer, BarChart, Bar, Tooltip, XAxis, Cell } from 'recharts';function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs));}interface CirculationData { type: string; count: number; color: string; [key: string]: any;}interface LibraryStatsCardProps { className?: string; title?: string; subtitle?: string; data?: CirculationData[];}const DEFAULT_DATA: CirculationData[] = [ { type: 'Out', count: 145, color: '#10b981' }, { type: 'Overdue', count: 12, color: '#ef4444' }, { type: 'Lost', count: 3, color: '#f59e0b' },];const DEFAULT_TITLE = "Circulation";const DEFAULT_SUBTITLE = "Library Stats";export const LibraryStatsCard: React.FC<LibraryStatsCardProps> = ({ className = "", title = DEFAULT_TITLE, subtitle = DEFAULT_SUBTITLE, data = DEFAULT_DATA,}) => { return ( <motion.div initial={{ opacity: 0, y: 20 }} animate={{ opacity: 1, y: 0 }} transition={{ duration: 0.5, delay: 0.4 }} className={cn( "relative overflow-hidden rounded-2xl border border-border bg-card text-card-foreground shadow-sm transition-all hover:border-teal-300 dark:hover:border-teal-700 hover:shadow-md flex flex-col h-full", className )} > <div className="p-5 flex flex-col h-full relative z-10"> <div className="mb-4 flex items-start justify-between"> <div> <h3 className="font-bold text-lg text-foreground"> {title} </h3> <p className="text-sm text-muted-foreground font-medium"> {subtitle} </p> </div> <div className="rounded-xl bg-teal-500/10 p-2.5 text-teal-500 dark:text-teal-400 flex items-center justify-center ring-1 ring-teal-100 dark:ring-teal-800"> <BookOpen className="h-5 w-5" /> </div> </div> <div className="flex-1 w-full min-h-[100px]"> <ResponsiveContainer width="100%" height="100%"> <BarChart data={data}> <XAxis dataKey="type" axisLine={false} tickLine={false} tick={{ fontSize: 10, fill: '#71717a' }} /> <Tooltip cursor={false} content={() => null} /> <Bar dataKey="count" radius={[4, 4, 0, 0]}> {data.map((entry, index) => ( <Cell key={`cell-${index}`} fill={entry.color} /> ))} </Bar> </BarChart> </ResponsiveContainer> </div> </div> <div className="absolute -bottom-4 -right-4 z-0 opacity-5 pointer-events-none"> <BookOpen className="w-32 h-32 text-teal-500" /> </div> </motion.div > );};Usage
This component helps library administrators monitor circulation statistics and track overdue materials.
Prop
Type