Animated Usage Card
An animated version of usage-card with smooth spring animations powered by motion.
Installation
npx shadcn@latest add "https://billui.com/r/animated-usage-card.json""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 codeExamples
Basic Usage
Simple usage card with animated progress bar and itemized list.
With Animated Meters
Use AnimatedUsageCardMeter to show individual resource usage with animated progress bars and number interpolation.
Collapsible List
Enable collapsible on AnimatedUsageCardList to show a preview with bouncy expand/collapse animation.
With Animated Total
The AnimatedUsageCardTotal row animates in with a bounce effect and the amount value interpolates smoothly.
Elevated Variant
Use variant="elevated" to add a shadow for more visual prominence.
API Reference
AnimatedUsageCard
The root container component with entrance animation.
| Prop | Type | Default |
|---|---|---|
variant | "default" | "elevated" | "default" |
AnimatedUsageCardPeriod
Displays the billing period or days remaining.
| Prop | Type | Default |
|---|---|---|
daysRemaining | number | — |
AnimatedUsageCardAction
Action button in the header. Extends shadcn Button props.
| Prop | Type | Default |
|---|---|---|
variant | "default" | "outline" | "ghost" | "outline" |
AnimatedUsageCardLabel
Displays a labeled amount with optional limit.
| Prop | Type | Default |
|---|---|---|
label | string | — |
amount | number | — |
limit | number | — |
currency | string | "$" |
align | "left" | "right" | "left" |
AnimatedUsageCardProgress
Animated progress bar showing usage against a limit with spring physics.
| Prop | Type | Default |
|---|---|---|
value | number | — |
max | number | 100 |
showOverage | boolean | false |
AnimatedUsageCardList
Container for usage items with optional bouncy expand/collapse animation.
| Prop | Type | Default |
|---|---|---|
collapsible | boolean | false |
defaultExpanded | boolean | false |
visibleItems | number | 1.5 |
dividers | boolean | true |
AnimatedUsageCardItem
Individual usage line item.
| Prop | Type | Default |
|---|---|---|
highlighted | boolean | false |
AnimatedUsageCardItemValue
Value display for a usage item.
| Prop | Type | Default |
|---|---|---|
amount | number | — |
currency | string | "$" |
unit | string | — |
AnimatedUsageCardMeter
Visual meter showing resource usage with animated progress and number interpolation.
| Prop | Type | Default |
|---|---|---|
used | number | — |
limit | number | — |
label | string | — |
unit | string | — |
showPercentage | boolean | false |
AnimatedUsageCardTotal
Animated total row with entrance animation and number interpolation.
| Prop | Type | Default |
|---|---|---|
label | string | "Total" |
amount | number | — |
currency | string | "$" |
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:
AnimatedUsageCardListusesvisibleItems(number of items) instead ofcollapsedHeight(pixels)