Components / AI Dashboards

AI Analytics Card

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

Live Preview — ai-analytics-card-01
Model Calls
Last 7 days usage
1.2K
14.2%

Installation

Dependencies

Install the core libraries required for this component.

npm
npm install lucide-react recharts

Shadcn UI Setup

Add the necessary Shadcn UI primitives.

npm
npx shadcn-ui@latest add card chart

Source Code

ai-analytics-card-01.tsx
"use client";

import {
    Card,
    CardHeader,
    CardTitle,
    CardDescription,
    CardContent,
} from "@/components/ui/card";
import { ArrowUp, ArrowDown } from "lucide-react";
import {
    ChartContainer,
    ChartTooltip,
    ChartTooltipContent,
} from "@/components/ui/chart";
import {
    BarChart,
    Bar,
    XAxis,
    CartesianGrid,
    ResponsiveContainer,
} from "recharts";

interface AIAnalyticsCard01Props {
    title?: string;
    description?: string;
    metric?: number | string;
    change?: number;
    data?: { label: string; value: number }[];
}

export default function AIAnalyticsCard01({
    title = "Model Calls",
    description = "Last 7 days usage",
    metric = "1.2K",
    change = 14.2,
    data = [
        { label: "Mon", value: 12 },
        { label: "Tue", value: 19 },
        { label: "Wed", value: 27 },
        { label: "Thu", value: 23 },
        { label: "Fri", value: 30 },
        { label: "Sat", value: 24 },
        { label: "Sun", value: 32 },
    ],
}: AIAnalyticsCard01Props) {
    const isPositive = change >= 0;

    return (
        <Card className="border-0 p-4 pb-0 w-full">
            <CardHeader className="p-0">
                <CardTitle className="text-sm">{title}</CardTitle>
                <CardDescription className="text-xs text-muted-foreground">
                    {description}
                </CardDescription>
            </CardHeader>

            <CardContent className="p-0 flex flex-col gap-2">
                <div className="flex items-center justify-between">
                    <span className="text-2xl font-bold">{metric}</span>
                    <div
                        className={
                            isPositive
                                ? "flex items-center text-green-600 text-sm font-medium"
                                : "flex items-center text-red-600 text-sm font-medium"
                        }
                    >
                        {isPositive ? (
                            <ArrowUp className="w-4 h-4 mr-1" />
                        ) : (
                            <ArrowDown className="w-4 h-4 mr-1" />
                        )}
                        {Math.abs(change)}%
                    </div>
                </div>

                {/* ShadCN Chart using Recharts */}
                <div className="h-[240px] mt-6 w-full">
                    <ChartContainer
                        config={{
                            value: { label: "Usage", color: "var(--color-chart-1)" },
                        }}
                        className="h-full w-full"
                    >
                        <ResponsiveContainer>
                            <BarChart data={data}>
                                <CartesianGrid vertical={false} />
                                <XAxis
                                    dataKey="label"
                                    tickLine={false}
                                    axisLine={false}
                                />
                                <ChartTooltip content={<ChartTooltipContent />} />
                                <Bar dataKey="value" fill="var(--color-chart-1)" radius={12} />
                            </BarChart>
                        </ResponsiveContainer>
                    </ChartContainer>
                </div>
            </CardContent>
        </Card>
    );
}

Shadcn Components

Primitives required in your @/components/ui directory.

Component Path
card @/components/ui/card
chart @/components/ui/chart

Type Reference

Types and interfaces defined in this component.

AIAnalyticsCard01Props
interface AIAnalyticsCard01Props {
    title?: string;
    description?: string;
    metric?: number | string;
    change?: number;
    data?: { label: string; value: number }[];
}

Functional Logic

Internal functions used to handle component logic.

Function Parameters
AIAnalyticsCard01() { title = "Model Calls", description = "Last 7 days usage", metric = "1.2K", change = 14.2, data = [ { label: "Mon", value: 12 }, { label: "Tue", value: 19 }, { label: "Wed", value: 27 }, { label: "Thu", value: 23 }, { label: "Fri", value: 30 }, { label: "Sat", value: 24 }, { label: "Sun", value: 32 }, ], }: AIAnalyticsCard01Props

Variables

All variable declarations found in this component.

Name Kind Value
isPositive const change >= 0

JSX Tags Usage

Every JSX/HTML tag used in this component, with usage count and source.

Tag Count Type Source
<ArrowDown> Library lucide-react
<ArrowUp> Library lucide-react
<Bar> Library recharts
<BarChart> Library recharts
<Card> Library @/components/ui/card
<CardContent> Library @/components/ui/card
<CardDescription> Library @/components/ui/card
<CardHeader> Library @/components/ui/card
<CardTitle> Library @/components/ui/card
<CartesianGrid> Library recharts
<ChartContainer> Library @/components/ui/chart
<ChartTooltip> Library @/components/ui/chart
<ChartTooltipContent> Library @/components/ui/chart
<ResponsiveContainer> Library recharts
<XAxis> Library recharts
<div> Native Native HTML
<span> Native Native HTML

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.