Billing SDK/Billing SDK
Billing & Usage AnalyticsDetailed Usage Table

Detailed Usage Table

The Detailed Usage Table component provides a comprehensive breakdown of resource consumption with columns for resource name, used amount, limit, and percentage utilization. The percentage field is now optional and will be automatically calculated if not provided.

Playground
Resource Usage
Detailed breakdown of your resource consumption
Detailed usage of resources
ResourceUsedLimitUsage
API Calls12,300 calls20,000 calls
62%
Storage850 GB1,000 GB
85%
Team Members4 users5 users
80%
Bandwidth1,500 GB2,000 GB
75%
Emails8,500 emails10,000 emails
85%
src/components/detailed-usage-table-demo.tsx
'use client';

import { DetailedUsageTable } from '@/components/billingsdk/detailed-usage-table';

export function DetailedUsageTableDemo() {
   return (
      <DetailedUsageTable
         title="Resource Usage"
         description="Detailed breakdown of your resource consumption"
         resources={[
            {
               name: 'API Calls',
               used: 12300,
               limit: 20000,
               // percentage will be automatically calculated as 61.5%
               unit: 'calls',
            },
            { name: 'Storage', used: 850, limit: 1000, percentage: 85, unit: 'GB' },
            {
               name: 'Team Members',
               used: 4,
               limit: 5,
               // percentage will be automatically calculated as 80%
               unit: 'users',
            },
            {
               name: 'Bandwidth',
               used: 1500,
               limit: 2000,
               percentage: 75,
               unit: 'GB',
            },
            {
               name: 'Emails',
               used: 8500,
               limit: 10000,
               // percentage will be automatically calculated as 85%
               unit: 'emails',
            },
         ]}
      />
   );
}

Installation

npx shadcn@latest add @billingsdk/detailed-usage-table
pnpm dlx shadcn@latest add @billingsdk/detailed-usage-table
yarn dlx shadcn@latest add @billingsdk/detailed-usage-table
bunx shadcn@latest add @billingsdk/detailed-usage-table
npx @billingsdk/cli add detailed-usage-table
pnpm dlx @billingsdk/cli add detailed-usage-table
yarn dlx @billingsdk/cli add detailed-usage-table
bunx @billingsdk/cli add detailed-usage-table

Usage

import { DetailedUsageTable } from '@/components/billingsdk/detailed-usage-table';
<DetailedUsageTable
	title="Resource Usage"
	description="Detailed breakdown of your resource consumption"
	resources={[
		{
			name: 'API Calls',
			used: 12300,
			limit: 20000,
			// percentage will be automatically calculated as 61.5%
			unit: 'calls',
		},
		{ name: 'Storage', used: 850, limit: 1000, percentage: 85, unit: 'GB' },
		{ name: 'Team Members', used: 4, limit: 5, unit: 'users' }, // percentage will be automatically calculated as 80%
	]}
/>;

Props

PropTypeDescription
classNamestringAdditional CSS classes to apply to the component
titlestringTitle for the usage table section
descriptionstringDescription for the usage table section
resourcesUsageResource[]Array of resource usage data

UsageResource Object

PropertyTypeDescription
namestringName of the resource
usednumberAmount of the resource used
limitnumberTotal limit for the resource
percentagenumber optionalPercentage of resource used (automatically calculated if not provided)
unitstringUnit of measurement (optional)
<DetailedUsageTable
	title="Monthly Resource Consumption"
	description="Track your usage across all plan resources"
	resources={[
		{
			name: 'API Requests',
			used: 45210,
			limit: 50000,
			// percentage will be automatically calculated as 90.4%
			unit: 'requests',
		},
		{
			name: 'File Storage',
			used: 750,
			limit: 1000,
			percentage: 75,
			unit: 'GB',
		},
		{ name: 'Team Seats', used: 8, limit: 5, unit: 'seats' }, // percentage will be automatically calculated as 160%
		{
			name: 'Bandwidth',
			used: 1850,
			limit: 2000,
			// percentage will be automatically calculated as 92.5%
			unit: 'GB',
		},
	]}
/>

Credits