Billing Estimate Calculator
A usage-based price calculator for pay-as-you-go or metered SaaS plans. Each resource, such as seats, API calls, or storage, gets its own slider with an included allotment and a per-unit rate above that. The total recalculates on every drag, and a monthly/yearly toggle applies a discount to the annual total. Built for pricing pages where the ideal plan depends on how much someone actually uses.
Docs
Installation
A real shadcn registry command, not a copy-paste stand-in: it fetches this block plus its button dependencies and any missing npm packages, and installs them straight into your project.
npx shadcn add https://staaarter.com/r/billing-estimate-calculator.jsonPrefer not to use the CLI? Copy the source from the Code toggle above into src/components/blocks/billing/billing56.tsx instead.
Usage
The file also exports billing56Demo, the exact props behind the preview above. Spread it to get a working section in one line, then replace it with your own data.
import { Billing56, billing56Demo } from "@/components/blocks/billing/billing56"; export default function Page() { return <Billing56 {...billing56Demo} />; }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| heading | string | "Estimate your bill" | Heading above the sliders. |
| description | string | none | Supporting sentence under the heading. |
| resources | EstimateResource[] | none | One slider per entry, rendered in the order given. |
| basePrice | number | 0 | Flat monthly platform fee added on top of every resource's cost. |
| defaultInterval | "monthly" | "yearly" | "monthly" | Which billing interval is active on first render. |
| yearlyDiscountPercent | number | 20 | Percentage discount applied to the total when yearly is selected. |
| ctaLabel | string | "Get this plan" | Label on the bottom call-to-action button. |
| className | string | none | Extra classes for the outer card. |
Types
interface EstimateResource { id: string; label: string; unit: string; min: number; max: number; step: number; defaultValue: number; pricePerUnit: number; includedUnits?: number; }
Behavior notes
- Sliders are native input type=range elements, not a shadcn/ui primitive, since the base UI kit doesn't ship a slider component.
- Each resource's billable amount is Math.max(0, quantity - includedUnits), multiplied by pricePerUnit. Nothing is billed below the included allotment.
- The monthly total is basePrice plus every resource's cost; line items are recomputed with useMemo whenever a slider value changes.
- The yearly toggle multiplies the monthly total by (1 - yearlyDiscountPercent / 100) and shows that as the monthly-equivalent, with the full annual charge underneath.
- The bottom CTA button doesn't submit or link anywhere on its own; wrap it in a Link render or add an onClick for a real checkout flow.
Frequently asked questions
More Billing Blocks
View all →Billing Invoice List
Invoice history table with status badges, formatted amounts, and a per-row download link, built with shadcn/ui and Tailwind CSS.
Billing Failed Payment Alert
High-contrast failed-payment alert with a message, a retry button, and an optional update-payment-method button, built with shadcn/ui and Tailwind CSS.
Billing Credit Balance
Compact credit balance card with a large total, an optional purchased-versus-promotional breakdown, a low-balance notice, and a top-up button.
Billing Payment Methods
A saved payment method list for React and Next.js with brand icons, a default badge, near-expiry warnings, and remove/set-default actions per row.
Billing Add Card
A card entry form for React and Next.js with auto-formatted fields, internal brand detection, and per-field validation feedback built with shadcn/ui and Tailwind CSS.
Billing Coupon Code
An inline promo code input for React and Next.js with a simulated loading state, an applied summary showing the discount amount, and an invalid-code message.