B

Usage Card

A card for displaying usage metrics, billing cycle progress and itemized charges.

12 days remaining in cycle
Credits Used347.00 / 500
Remaining153.00
Image Generation120 credits
Video Generation85 credits
Upscaling (4x)62 credits
Background Removal45 credits
Style Transfer35 credits

Installation

npx shadcn@latest add "https://billui.com/r/usage-card.json"
components/ui/usage-card.tsx
"use client";

import { cva, type VariantProps } from "class-variance-authority";
import { ChevronDown, ChevronUp } from "lucide-react";
import * as React from "react";
import { cn } from "@/lib/utils";
import { Button } from "@/components/ui/button";
import { Progress } from "@/components/ui/progress";

// ... component code

Examples

Basic Usage

Simple usage card with progress bar and itemized list.

14 days remaining in cycle
Used$12.50 / $20
API Calls$8.50
Storage$4.00

Elevated Variant

Use variant="elevated" to add a shadow for more visual prominence.

7 days remaining in cycle
Credits Used$18.50 / $20
On-Demand$0.00

With Usage Meters

Use UsageCardMeter to show individual resource usage with visual progress bars.

5 days remaining in cycle
API Requests8,500 req / 10,000 req(85%)
Storage4.2 GB / 5 GB(84%)
Bandwidth950 GB / 1,000 GB(95%)

Collapsible List

Enable collapsible on UsageCardList to show a preview with expand/collapse functionality.

3 days remaining in cycle
Build Minutes$4.02
Edge Invocations$0.65
Function Calls$0.60
Bandwidth$0.34

With Highlighted Items

Use highlighted prop on items to create zebra striping.

Compute$12.50
Storage$5.00
Bandwidth$2.50
Functions$1.25

With Total Row

Add a UsageCardTotal at the bottom to show the sum of all charges.

2 days remaining in cycle
Pro Plan$29.00
Extra Seats (3)$45.00
Storage Add-on$10.00
Total$84.00

Overage Warning

The progress bar turns red when usage exceeds the limit.

Billing cycle exceeded
Used$28.50 / $20
Overage$8.50

Custom Currency

Display amounts in different currencies.

Créditos Usados15.00 / 50
Adicional0.00
Almacenamiento10.00
Transferencia5.00
Total15.00

Custom Period Text

Pass custom children to UsageCardPeriod for custom text.

Jan 1 - Jan 31, 2024
Total Used$45.00

API Reference

UsageCard

The root container component.

PropTypeDefault
variant"default" | "elevated""default"

UsageCardPeriod

Displays the billing period or days remaining.

PropTypeDefault
daysRemainingnumber

UsageCardAction

Action button in the header.

PropTypeDefault
variant"default" | "outline" | "ghost""outline"

UsageCardLabel

Displays a labeled amount with optional limit.

PropTypeDefault
labelstring
amountnumber
limitnumber
currencystring"$"
align"left" | "right""left"

UsageCardProgress

Progress bar showing usage against a limit.

PropTypeDefault
valuenumber
maxnumber100
showOveragebooleanfalse

UsageCardList

Container for usage items with optional collapsing.

PropTypeDefault
collapsiblebooleanfalse
defaultExpandedbooleanfalse
collapsedHeightnumber88
dividersbooleantrue

UsageCardItem

Individual usage line item.

PropTypeDefault
highlightedbooleanfalse

UsageCardItemValue

Value display for a usage item.

PropTypeDefault
amountnumber
currencystring"$"
unitstring

UsageCardMeter

Visual meter showing resource usage with warning states.

PropTypeDefault
usednumber
limitnumber
labelstring
unitstring
showPercentagebooleanfalse

UsageCardTotal

Total row at the bottom of the card.

PropTypeDefault
labelstring"Total"
amountnumber
currencystring"$"

useUsageCardList

Hook to access the list expansion state from child components.

const { expanded, setExpanded, itemCount, collapsedHeight } = useUsageCardList();

On this page