Components / AI Dashboards

AI Cost Breakdown Chart

A visual cost breakdown showing AI spending by model with horizontal bar charts and total cost summary.

Live Preview — ai-cost-breakdown-01

Cost Breakdown

$264.20
GPT-4o
$124.5047%
Claude 3.5
$82.2031%
Gemini Pro
$45.1017%
Others
$12.405%

Installation

Dependencies

Install the core libraries required for this component.

npm
npm install react

Source Code

ai-cost-breakdown-01.tsx
"use client";

import React from "react";

const data = [
    { model: "GPT-4o", cost: 124.50, color: "bg-violet-500" },
    { model: "Claude 3.5", cost: 82.20, color: "bg-blue-500" },
    { model: "Gemini Pro", cost: 45.10, color: "bg-emerald-500" },
    { model: "Others", cost: 12.40, color: "bg-zinc-400" },
];

export default function AICostBreakdown() {
    const total = data.reduce((acc, curr) => acc + curr.cost, 0);

    return (
        <div className="rounded-xl border border-zinc-200 dark:border-zinc-800 bg-white dark:bg-zinc-950 p-6 shadow-sm w-full max-w-md mx-auto">
            <div className="flex items-center justify-between mb-6">
                <h3 className="text-sm font-bold text-zinc-900 dark:text-zinc-100">Cost Breakdown</h3>
                <span className="text-lg font-bold text-zinc-900 dark:text-zinc-100">${total.toFixed(2)}</span>
            </div>

            <div className="flex h-2 w-full rounded-full overflow-hidden bg-zinc-100 dark:bg-zinc-800 mb-6">
                {data.map((item) => (
                    <div
                        key={item.model}
                        className={item.color}
                        style={{ width: `${(item.cost / total) * 100}%` }}
                    />
                ))}
            </div>

            <div className="space-y-3">
                {data.map((item) => (
                    <div key={item.model} className="flex items-center justify-between text-xs">
                        <div className="flex items-center gap-2">
                            <div className={`h-2 w-2 rounded-full ${item.color}`} />
                            <span className="text-zinc-600 dark:text-zinc-400">{item.model}</span>
                        </div>
                        <div className="flex items-center gap-3">
                            <span className="text-zinc-900 dark:text-zinc-100 font-medium">${item.cost.toFixed(2)}</span>
                            <span className="text-zinc-400 w-8 text-right">{Math.round((item.cost / total) * 100)}%</span>
                        </div>
                    </div>
                ))}
            </div>
        </div>
    );
}

Functional Logic

Internal functions used to handle component logic.

Function Parameters
AICostBreakdown() None

Variables

All variable declarations found in this component.

Name Kind Value
data const [
total const data.reduce((acc, curr) => acc + curr.cost, 0)

JSX Tags Usage

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

Tag Count Type Source
<div> Native Native HTML
<h3> Native Native HTML
<span> Native Native HTML

Related Components

  • AI Analytics Card — A dashboard analytics card showing AI model usage metrics with sparkline charts, percentage changes, and trend indicators.
  • 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 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.