Usage card
A concentric usage meter card with semantic threshold status pills, tabular quota readouts, and an inline-labeled progress bar.
Props
Installation
Usage card is published as a shadcn registry item. The CLI drops the file into your project, installs its dependencies, and adds any primitives it relies on.
$npx shadcn@latest add @akoder/usage-cardThe @akoder namespace ships with the shadcn CLI, so there is nothing to configure first. Install any other component the same way from the Components page.
Usage
label, value, and limit are required. The component renders one card, so you can stack multiple meters in a billing panel or arrange them in a dashboard grid.
Thresholds and status
By default, UsageCard derives its semantic status from the rounded usage percentage:
- Below
dangerThreshold(default80), the card rendersgoodwith a neutral progress fill and a greenGoodbadge. - At or above
dangerThreshold, the card rendersaction-requiredwith a red progress fill, red percentage readout, and a redAction requiredbadge. - When
warningThresholdis set belowdangerThreshold, values in between renderwarningwith an amber progress fill, amber percentage readout, and an amberWarningbadge.
The status pill reuses WorkflowStatusBadge (@akoder/workflow-status), which the shadcn CLI installs automatically as a registry dependency.
Pass status explicitly to override automatic threshold derivation, use statusLabel or statusIcon to customize the badge, or pass showStatus={false} to omit the pill.
Formatting
Large integers with five or more digits format with space grouping by default (82 540 / 100 000), while four-digit totals stay compact (611 / 1000 gb). Formatting is deterministic across server and client renders to avoid locale hydration mismatches.
Use unit, formatValue, and formatPercentage to adapt the readout to currencies, durations, or custom copy:
The component also exports formatUsageNumber if you want to reuse the default number formatting outside the card.
Props
The component exports UsageCardProps, UsageCardStatus, usageCardStatuses, and formatUsageNumber. Additional props forward to the root div.
| Prop | Type | Default | Notes |
|---|---|---|---|
label Required | string | - | Metric heading in the top-left of the inner card. |
value Required | number | - | Current usage amount. Negative or nonfinite values clamp to 0. |
limit Required | number | - | Quota ceiling. Nonfinite or nonpositive values render 0%. |
unit | string | - | Optional unit suffix aligned to the baseline after limit. |
icon | ReactNode | - | Optional decorative icon shown before label. |
status | UsageCardStatus | derived | Explicit "good", "warning", or "action-required" state. |
statusLabel | string | state label | Custom text inside the status pill. |
statusIcon | LucideIcon | state icon | Custom icon forwarded to WorkflowStatusBadge. |
showStatus | boolean | true | Hides the status pill when false. |
dangerThreshold | number | 80 | Percentage (0 to 100) at or above which status becomes "action-required". |
warningThreshold | number | - | Optional percentage (0 to 100) at or above which status becomes "warning". |
formatValue | (amount: number) => string | formatUsageNumber | Formats both value and limit. |
formatPercentage | (percent: number) => string | `${percent}% used` | Formats the inline progress label and aria-valuetext. |
className | string | - | Extra classes merged onto the outer tray. |
Accessibility and notes
- Progress semantics. The bottom tray renders
role="progressbar"witharia-label,aria-valuemin,aria-valuemax,aria-valuenow, andaria-valuetext. - State clarity. Each status pairs an icon, label, and semantic color via
WorkflowStatusBadge, so thresholds do not rely on color alone. - Boundary handling. At
0%, the filled bar collapses cleanly without a stray dot; at100%or above, the remaining track hides while the label continues reporting the actual rounded percentage. - Reduced motion. Progress bar transitions disable automatically when
prefers-reduced-motion: reduceis active. - Server-component friendly.
UsageCardhas no client-only hooks and works in both React Server Components and Client Components.
Manual installation
Rather not use the CLI? Everything Usage card needs is below. Install its dependencies, then copy the file into the matching path in your project.
Dependencies
$npm install lucide-reactshadcn primitives
$npx shadcn@latest add @akoder/workflow-statusSource