B

Animated Usage Card

An animated version of usage-card with smooth spring animations powered by motion.

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/animated-usage-card.json"
components/ui/animated-usage-card.tsx
"use client";

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

// ... component code

Examples

Basic Usage

Simple usage card with animated progress bar and itemized list.

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

With Animated Meters

Use AnimatedUsageCardMeter to show individual resource usage with animated progress bars and number interpolation.

5 days remaining in cycle
API Requests0 req / 10,000 req(0%)
Storage0 GB / 5 GB(0%)
Bandwidth0 GB / 1,000 GB(0%)

Collapsible List

Enable collapsible on AnimatedUsageCardList to show a preview with bouncy expand/collapse animation.

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

With Animated Total

The AnimatedUsageCardTotal row animates in with a bounce effect and the amount value interpolates smoothly.

2 days remaining in cycle
Pro Plan$29.00
Extra Seats (3)$45.00
Storage Add-on$10.00
Total$0.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

API Reference

AnimatedUsageCard

The root container component with entrance animation.

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

AnimatedUsageCardPeriod

Displays the billing period or days remaining.

PropTypeDefault
daysRemainingnumber

AnimatedUsageCardAction

Action button in the header. Extends shadcn Button props.

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

AnimatedUsageCardLabel

Displays a labeled amount with optional limit.

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

AnimatedUsageCardProgress

Animated progress bar showing usage against a limit with spring physics.

PropTypeDefault
valuenumber
maxnumber100
showOveragebooleanfalse

AnimatedUsageCardList

Container for usage items with optional bouncy expand/collapse animation.

PropTypeDefault
collapsiblebooleanfalse
defaultExpandedbooleanfalse
visibleItemsnumber1.5
dividersbooleantrue

AnimatedUsageCardItem

Individual usage line item.

PropTypeDefault
highlightedbooleanfalse

AnimatedUsageCardItemValue

Value display for a usage item.

PropTypeDefault
amountnumber
currencystring"$"
unitstring

AnimatedUsageCardMeter

Visual meter showing resource usage with animated progress and number interpolation.

PropTypeDefault
usednumber
limitnumber
labelstring
unitstring
showPercentagebooleanfalse

AnimatedUsageCardTotal

Animated total row with entrance animation and number interpolation.

PropTypeDefault
labelstring"Total"
amountnumber
currencystring"$"

useAnimatedUsageCardList

Hook to access the list expansion state from child components.

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

Comparison with UsageCard

This component is API-compatible with the non-animated UsageCard. You can swap between them by changing the import:

// Without animations
import { UsageCard, UsageCardList, ... } from "@/components/ui/usage-card"

// With animations
import { AnimatedUsageCard, AnimatedUsageCardList, ... } from "@/components/ui/animated-usage-card"

The only API difference is:

  • AnimatedUsageCardList uses visibleItems (number of items) instead of collapsedHeight (pixels)

On this page