Billing SDK/Billing SDK
Subscription ManagementUsage-based Pricing

Usage-based Pricing

Interactive usage-based pricing with a ruler slider, 100-step grid, clickable 1,000-credit markers, and smooth animations.

Playground
Pay as you use pricing
Start with a flat monthly rate that includes 4,000 credits.
$39.99/mo

4,000 credits per month

4,000 credits25,000 credits
src/components/usage-based-pricing-demo.tsx
"use client"

import { UsageBasedPricing } from "@/components/billingsdk/usage-based-pricing"

export function UsageBasedPricingDemo() {
  return (
    <div className="flex flex-1 flex-col justify-center text-center">
      <UsageBasedPricing className="max-w-5xl mx-auto" />
    </div>
  )
}

Installation

npx shadcn@latest add @billingsdk/usage-based-pricing
pnpm dlx shadcn@latest add @billingsdk/usage-based-pricing
yarn dlx shadcn@latest add @billingsdk/usage-based-pricing
bunx shadcn@latest add @billingsdk/usage-based-pricing
npx @billingsdk/cli add usage-based-pricing
pnpm dlx @billingsdk/cli add usage-based-pricing
yarn dlx @billingsdk/cli add usage-based-pricing
bunx @billingsdk/cli add usage-based-pricing

Usage

import { useState } from "react";
import { UsageBasedPricing } from "@/components/billingsdk/usage-based-pricing";

export default function Page() {
  const [credits, setCredits] = useState(4000);
  return (
    <div className="flex flex-1 flex-col items-center justify-center text-center space-y-6">
      <UsageBasedPricing
        className="w-full max-w-5xl"
        min={4000}
        max={25001}
        snapTo={100}
        currency="$"
        basePrice={39.99}
        includedCredits={4000}
        value={credits}
        onChange={setCredits}
        onChangeEnd={(v) => console.log("Committed:", v)}
        title="Pay as you use pricing"
        subtitle="Start with a flat monthly rate that includes 4,000 credits."
      />
      <div className="text-xs text-muted-foreground">Current value: {credits.toLocaleString()} credits</div>
    </div>
  );
}

Features

  • Smooth, lag-free slider with animated tick heights and precise pointer tracking.
  • 100-credit live increments (configurable via snapTo).
  • Clickable 1,000-credit dots that animate to the target instead of teleporting.
  • Start/end labels centered beneath the first and last dots.
  • Keyboard accessible: Arrow keys move by base step (default 100), Shift+Arrow moves faster, Home/End jump to edges.
  • Price model example included: base price plus $10 per 1,000 credits above the included amount.

Props

PropTypeDefaultDescription
minnumber4000Minimum credits.
maxnumber25001Maximum credits.
valuenumberControlled value (credits).
defaultValuenumber4000Uncontrolled initial credits.
onChange(value: number) => voidCalled on value change during drag/animation.
onChangeEnd(value: number) => voidCalled when interaction completes.
stepnumber1Fine step (used for keyboard when snapTo not provided).
snapTonumberLive quantization step. If omitted, drag uses 100; release snaps to snapTo, else to step (>1), else to 100.
currencystring"$"Currency symbol.
basePricenumber39.99Base price covering included credits.
includedCreditsnumber4000Credits included in base price.
unitPricePerCreditnumber0.01Unit price (not used in the $10/1000 example model).
titlestring"Pay as you use pricing"Heading text.
subtitlestring"Start with a flat monthly rate that includes 4,000 credits."Subheading text.