Billing Custom Billing Cycle
A billing cycle block that lets someone pick between monthly, quarterly, annual, or any custom cycle you define. Selecting a cycle recalculates the effective monthly price and the total charged per cycle, and shows a savings badge on any cycle with a discount attached. Built with TypeScript, Tailwind CSS, and Lucide icons.
Docs
Installation
A real shadcn registry command, not a copy-paste stand-in: it fetches this block plus its badge dependencies and any missing npm packages, and installs them straight into your project.
npx shadcn add https://staaarter.com/r/billing-custom-billing-cycle.jsonPrefer not to use the CLI? Copy the source from the Code toggle above into src/components/blocks/billing/billing44.tsx instead.
Usage
The file also exports billing44Demo, 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 { Billing44, billing44Demo } from "@/components/blocks/billing/billing44"; export default function Page() { return <Billing44 {...billing44Demo} />; }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| heading | string | "Billing cycle" | Block heading. |
| description | string | none | Supporting text under the heading. |
| basePrice | number | none | Full monthly price before any cycle discount is applied. |
| cycles | BillingCycleOption[] | none | Cycle options rendered as toggle buttons, in the order given. |
| defaultCycleId | string | cycles[0].id | Which cycle is selected on first render. |
| note | string | "Cycle changes take effect at the end of your current period. Prorated adjustments may apply." | Small info line under the price, pass an empty string to hide it. |
| className | string | none | Extra classes for the outer container. |
Types
interface BillingCycleOption { id: string; label: string; months: number; discountPercent?: number; }
Behavior notes
- The selected cycle is local state, defaulting to defaultCycleId or the first entry in cycles.
- The displayed monthly price is basePrice reduced by the selected cycle's discountPercent, not a value read directly off the cycle object, so the price and the badge always agree.
- The per-cycle total shown under the price is the effective monthly price multiplied by that cycle's months.
- A cycle only shows a 'Save X%' badge when its discountPercent is set and greater than zero, cycles without a discount render as a plain label.
- The info note at the bottom is static text meant to set expectations about proration, it isn't computed from the actual switch and doesn't know the current invoice.
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.