Components / AI Dashboards

AI Analytics Card

A dashboard analytics card showing AI model usage metrics with sparkline charts, percentage changes, and trend indicators.

tsx
"use client";
import React from "react";
import { TrendingUp, TrendingDown } from "lucide-react";

interface Props { title: string; value: string; change: number; sparkline?: number[]; }

export default function AIAnalyticsCard({ title, value, change, sparkline = [20, 45, 28, 80, 55, 90, 72] }: Props) {
  const isPositive = change >= 0;
  const max = Math.max(...sparkline);
  const min = Math.min(...sparkline);
  return (
    <div className="rounded-xl border border-zinc-200 dark:border-zinc-800 bg-white dark:bg-zinc-950 p-5">
      <p className="text-sm text-zinc-500 mb-1">{title}</p>
      <div className="flex items-end justify-between mb-3">
        <p className="text-2xl font-bold text-zinc-900 dark:text-zinc-100 tracking-tight">{value}</p>
        <div className={`flex items-center gap-1 text-xs font-medium ${isPositive ? "text-emerald-500" : "text-red-500"}`}>
          {isPositive ? <TrendingUp className="h-3 w-3" /> : <TrendingDown className="h-3 w-3" />}
          {Math.abs(change)}%
        </div>
      </div>
      <div className="flex items-end gap-1 h-10">
        {sparkline.map((val, i) => (
          <div key={i} className={`flex-1 rounded-sm ${isPositive ? "bg-emerald-500/20" : "bg-red-500/20"}`} style={{ height: `${((val - min) / (max - min)) * 100}%`, minHeight: "4px" }} />
        ))}
      </div>
    </div>
  );
}

Installation

Dependencies

  • react
  • lucide-react
                            npm install react lucide-react
                        

Related Components

  • AI Token Usage Meter — A circular progress meter showing AI token consumption with remaining quota and cost estimation.
  • AI Model Performance Table — A comparison table showing AI model performance benchmarks with sortable columns for speed, accuracy, and cost.
  • AI Request Log — A real-time scrolling log of AI API requests with status indicators, response times, and token counts.
  • AI Cost Breakdown Chart — A visual cost breakdown showing AI spending by model with horizontal bar charts and total cost summary.
  • AI Service Status Badge — An AI service status indicator showing operational health with animated pulse dots and uptime percentages.
  • AI Activity Feed — A timestamped activity feed showing recent AI interactions, model changes, and system events with icon indicators.