Components / AI Dashboards
AI Token Usage Meter
A circular progress meter showing AI token consumption with remaining quota and cost estimation.
Components / AI Dashboards
A circular progress meter showing AI token consumption with remaining quota and cost estimation.
Token Limit
75 / 100 tokens
Install the core libraries required for this component.
npm install react"use client";
import React from "react";
interface AIUsageMeterProps {
value?: number;
max?: number;
title?: string;
}
export default function AIUsageMeter({
value = 75,
max = 100,
title = "Token Limit"
}: AIUsageMeterProps) {
const percentage = Math.min(Math.max((value / max) * 100, 0), 100);
const radius = 36;
const circumference = 2 * Math.PI * radius;
const offset = circumference - (percentage / 100) * circumference;
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-xs mx-auto flex flex-col items-center">
<div className="relative h-24 w-24">
<svg className="h-full w-full -rotate-90">
<circle
cx="48"
cy="48"
r={radius}
fill="transparent"
stroke="currentColor"
strokeWidth="8"
className="text-zinc-100 dark:text-zinc-800"
/>
<circle
cx="48"
cy="48"
r={radius}
fill="transparent"
stroke="currentColor"
strokeWidth="8"
strokeDasharray={circumference}
strokeDashoffset={offset}
strokeLinecap="round"
className="text-blue-500 transition-all duration-1000 ease-out"
/>
</svg>
<div className="absolute inset-0 flex flex-col items-center justify-center">
<span className="text-xl font-bold text-zinc-900 dark:text-zinc-100">{percentage}%</span>
</div>
</div>
<div className="mt-4 text-center">
<p className="text-sm font-medium text-zinc-900 dark:text-zinc-100">{title}</p>
<p className="text-xs text-zinc-500">{value.toLocaleString()} / {max.toLocaleString()} tokens</p>
</div>
</div>
);
} "use client";
import React from "react";
interface AIUsageMeterProps {
value?: number;
max?: number;
title?: string;
}
export default function AIUsageMeter({
value = 75,
max = 100,
title = "Token Limit"
}: AIUsageMeterProps) {
const percentage = Math.min(Math.max((value / max) * 100, 0), 100);
const radius = 36;
const circumference = 2 * Math.PI * radius;
const offset = circumference - (percentage / 100) * circumference;
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-xs mx-auto flex flex-col items-center">
<div className="relative h-24 w-24">
<svg className="h-full w-full -rotate-90">
<circle
cx="48"
cy="48"
r={radius}
fill="transparent"
stroke="currentColor"
strokeWidth="8"
className="text-zinc-100 dark:text-zinc-800"
/>
<circle
cx="48"
cy="48"
r={radius}
fill="transparent"
stroke="currentColor"
strokeWidth="8"
strokeDasharray={circumference}
strokeDashoffset={offset}
strokeLinecap="round"
className="text-blue-500 transition-all duration-1000 ease-out"
/>
</svg>
<div className="absolute inset-0 flex flex-col items-center justify-center">
<span className="text-xl font-bold text-zinc-900 dark:text-zinc-100">{percentage}%</span>
</div>
</div>
<div className="mt-4 text-center">
<p className="text-sm font-medium text-zinc-900 dark:text-zinc-100">{title}</p>
<p className="text-xs text-zinc-500">{value.toLocaleString()} / {max.toLocaleString()} tokens</p>
</div>
</div>
);
} Types and interfaces defined in this component.
interface AIUsageMeterProps {
value?: number;
max?: number;
title?: string;
} interface AIUsageMeterProps {
value?: number;
max?: number;
title?: string;
} Internal functions used to handle component logic.
| Function | Parameters |
|---|---|
| AIUsageMeter() | { value = 75, max = 100, title = "Token Limit" }: AIUsageMeterProps |
All variable declarations found in this component.
| Name | Kind | Value |
|---|---|---|
| percentage | | Math.min(Math.max((value / max) * 100, 0), 100) |
| radius | | 36 |
| circumference | | 2 * Math.PI * radius |
| offset | | circumference - (percentage / 100) * circumference |
Every JSX/HTML tag used in this component, with usage count and source.
| Tag | Count | Type | Source |
|---|---|---|---|
| <circle> | 2× | | Native HTML |
| <div> | 4× | | Native HTML |
| <p> | 2× | | Native HTML |
| <span> | 1× | | Native HTML |
| <svg> | 1× | | Native HTML |