Usage Card

A card component for displaying usage metrics with progress bars, color-coded states, and limit indicators

Loading...
pnpm dlx @sikka/naseem add usage-card
npx @sikka/naseem add usage-card
yarn dlx @sikka/naseem add usage-card
bunx --bun @sikka/naseem add usage-card

Usage

import { UsageCard } from "@/components/naseem-ui/elements/usage-card";
import { Mail } from "lucide-react";

export default function Example() {
  return (
    <UsageCard
      icon={Mail}
      title="Emails"
      used={850}
      limit={1000}
      percentage={85}
    />
  );
}

Features

  • Color-coded states — Automatic green, amber, and red coloring based on usage percentage (70% warning, 90% danger)
  • Limit reached indicator — Shows a destructive message when the limit is reached
  • Unlimited support — Pass a string as limit to hide the progress bar and show unlimited mode
  • Custom icon — Accepts any React element type as the icon
  • i18n ready — The limitReachedText prop allows customizing the limit reached message

Props

PropTypeDefaultDescription
iconReact.ElementTyperequiredIcon component to display
titlestringrequiredTitle of the usage metric
usednumberrequiredCurrent usage count
limitnumber | stringrequiredUsage limit — number for numeric, string (e.g. "Unlimited") for unlimited
percentagenumberrequiredUsage percentage (0–100)
limitReachedbooleanfalseWhether the limit has been reached
limitReachedTextstring"Limit reached"Text displayed when limit is reached
classNamestringundefinedAdditional class name for the card

Color States

ConditionColorDescription
percentage >= 90 or limitReachedRed (destructive)Critical usage
percentage >= 70AmberWarning usage
percentage < 70Primary (default)Normal usage

Examples

With Limit Reached

<UsageCard
  icon={Users}
  title="Team members"
  used={10}
  limit={10}
  percentage={100}
  limitReached
  limitReachedText="Upgrade to add more"
/>

Unlimited Plan

<UsageCard
  icon={Zap}
  title="API calls"
  used={12400}
  limit="Unlimited"
  percentage={0}
/>

Grid Layout

<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-4">
  <UsageCard icon={Mail} title="Emails" used={850} limit={1000} percentage={85} />
  <UsageCard icon={Database} title="Storage" used={95} limit={100} percentage={95} />
  <UsageCard icon={Users} title="Users" used={10} limit={10} percentage={100} limitReached />
  <UsageCard icon={Zap} title="API calls" used={12400} limit="Unlimited" percentage={0} />
</div>

Custom Limit Text

<UsageCard
  icon={Mail}
  title="Emails"
  used={1000}
  limit={1000}
  percentage={100}
  limitReached
  limitReachedText="Upgrade your plan to send more emails"
/>

File Structure

components/naseem-ui/elements/
├── usage-card.tsx       # Usage card component
components/ui/
├── progress.tsx         # Progress bar component (dependency)

On this page