Usage Card
A card for displaying usage metrics, billing cycle progress and itemized charges.
Installation
npx shadcn@latest add "https://billui.com/r/usage-card.json""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 codeExamples
Basic Usage
Simple usage card with progress bar and itemized list.
Elevated Variant
Use variant="elevated" to add a shadow for more visual prominence.
With Usage Meters
Use UsageCardMeter to show individual resource usage with visual progress bars.
Collapsible List
Enable collapsible on UsageCardList to show a preview with expand/collapse functionality.
With Highlighted Items
Use highlighted prop on items to create zebra striping.
With Total Row
Add a UsageCardTotal at the bottom to show the sum of all charges.
Overage Warning
The progress bar turns red when usage exceeds the limit.
Custom Currency
Display amounts in different currencies.
Custom Period Text
Pass custom children to UsageCardPeriod for custom text.
API Reference
UsageCard
The root container component.
| Prop | Type | Default |
|---|---|---|
variant | "default" | "elevated" | "default" |
UsageCardPeriod
Displays the billing period or days remaining.
| Prop | Type | Default |
|---|---|---|
daysRemaining | number | — |
UsageCardAction
Action button in the header.
| Prop | Type | Default |
|---|---|---|
variant | "default" | "outline" | "ghost" | "outline" |
UsageCardLabel
Displays a labeled amount with optional limit.
| Prop | Type | Default |
|---|---|---|
label | string | — |
amount | number | — |
limit | number | — |
currency | string | "$" |
align | "left" | "right" | "left" |
UsageCardProgress
Progress bar showing usage against a limit.
| Prop | Type | Default |
|---|---|---|
value | number | — |
max | number | 100 |
showOverage | boolean | false |
UsageCardList
Container for usage items with optional collapsing.
| Prop | Type | Default |
|---|---|---|
collapsible | boolean | false |
defaultExpanded | boolean | false |
collapsedHeight | number | 88 |
dividers | boolean | true |
UsageCardItem
Individual usage line item.
| Prop | Type | Default |
|---|---|---|
highlighted | boolean | false |
UsageCardItemValue
Value display for a usage item.
| Prop | Type | Default |
|---|---|---|
amount | number | — |
currency | string | "$" |
unit | string | — |
UsageCardMeter
Visual meter showing resource usage with warning states.
| Prop | Type | Default |
|---|---|---|
used | number | — |
limit | number | — |
label | string | — |
unit | string | — |
showPercentage | boolean | false |
UsageCardTotal
Total row at the bottom of the card.
| Prop | Type | Default |
|---|---|---|
label | string | "Total" |
amount | number | — |
currency | string | "$" |
useUsageCardList
Hook to access the list expansion state from child components.
const { expanded, setExpanded, itemCount, collapsedHeight } = useUsageCardList();