Upcoming Charge
Next billing date and amount with a short breakdown and payment method.
"use client"
import { useState } from "react"
import { CalendarIcon } from "@phosphor-icons/react"
import { Button } from "@/components/ui/button"
import {
Card,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from "@/components/ui/card"
import {
Dialog,
DialogClose,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog"
import { Label } from "@/components/ui/label"
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"
const COPY = {
title: "Upcoming charge",
description: "Here is what we will bill you next.",
amount: "$92.00",
date: "December 3, 2026",
viewInvoice: "Preview invoice",
hideInvoice: "Hide invoice",
invoiceTotal: "Total due",
changeMethod: "Change method",
dialogTitle: "Change payment method",
dialogDescription: "Choose the card we charge on the date above.",
save: "Use this card",
cancel: "Cancel",
}
const BREAKDOWN = [
{ id: "b1", label: "Studio plan", amount: "$48.00" },
{ id: "b2", label: "5 seats", amount: "$36.00" },
{ id: "b3", label: "Storage add-on", amount: "$8.00" },
]
const METHODS = [
{ id: "visa", label: "Visa ending 4242" },
{ id: "mastercard", label: "Mastercard ending 8210" },
{ id: "amex", label: "Amex ending 3005" },
]
export default function BillingUpcomingCharge() {
const [showInvoice, setShowInvoice] = useState(false)
const [open, setOpen] = useState(false)
const [methodId, setMethodId] = useState(METHODS[0].id)
const [draftId, setDraftId] = useState(METHODS[0].id)
const method = METHODS.find((m) => m.id === methodId) ?? METHODS[0]
return (
<Card className="mx-auto w-full max-w-md">
<CardHeader>
<CardTitle>{COPY.title}</CardTitle>
<CardDescription>{COPY.description}</CardDescription>
</CardHeader>
<CardContent className="flex flex-col gap-5">
<div className="flex items-center gap-4 rounded-2xl bg-muted p-4">
<span className="flex size-11 items-center justify-center rounded-xl bg-background">
<CalendarIcon className="size-5" />
</span>
<div className="flex flex-col">
<span className="text-2xl font-semibold tabular-nums">
{COPY.amount}
</span>
<span className="text-xs text-muted-foreground">
{COPY.date} · {method.label}
</span>
</div>
</div>
{showInvoice && (
<ul className="flex flex-col gap-2 text-sm">
{BREAKDOWN.map((row) => (
<li key={row.id} className="flex justify-between">
<span className="text-muted-foreground">{row.label}</span>
<span className="tabular-nums">{row.amount}</span>
</li>
))}
<li className="flex justify-between border-t pt-2 font-medium">
<span>{COPY.invoiceTotal}</span>
<span className="tabular-nums">{COPY.amount}</span>
</li>
</ul>
)}
</CardContent>
<CardFooter className="gap-2">
<Button
variant="outline"
className="flex-1"
aria-expanded={showInvoice}
onClick={() => setShowInvoice((v) => !v)}
>
{showInvoice ? COPY.hideInvoice : COPY.viewInvoice}
</Button>
<Dialog
open={open}
onOpenChange={(next) => {
setOpen(next)
if (next) setDraftId(methodId)
}}
>
<DialogTrigger render={<Button variant="ghost" />}>
{COPY.changeMethod}
</DialogTrigger>
<DialogContent>
<DialogHeader>
<DialogTitle>{COPY.dialogTitle}</DialogTitle>
<DialogDescription>{COPY.dialogDescription}</DialogDescription>
</DialogHeader>
<RadioGroup value={draftId} onValueChange={setDraftId}>
{METHODS.map((m) => (
<div key={m.id} className="flex items-center gap-3">
<RadioGroupItem id={`method-${m.id}`} value={m.id} />
<Label htmlFor={`method-${m.id}`}>{m.label}</Label>
</div>
))}
</RadioGroup>
<DialogFooter>
<DialogClose render={<Button variant="outline" />}>
{COPY.cancel}
</DialogClose>
<Button
onClick={() => {
setMethodId(draftId)
setOpen(false)
}}
>
{COPY.save}
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
</CardFooter>
</Card>
)
}
Installation
pnpm dlx shadcn@latest add @01orbital/upcoming-charge-01npx shadcn@latest add @01orbital/upcoming-charge-01yarn dlx shadcn@latest add @01orbital/upcoming-charge-01bunx --bun shadcn@latest add @01orbital/upcoming-charge-01Make it yours
- Its words are in
COPYat the top ofcomponents/blocks/billing/upcoming-charge-01/index.tsx: change them there, not in the markup. BREAKDOWNandMETHODS, also at the top of the file, hold its lists and settings.
Built from
npm: @phosphor-icons/react. The CLI installs it for you.
Built from these parts. The CLI adds each one that is missing and won't replace a file you already have unless you choose to:
The shadcn parts here are their Base UI versions, and this piece uses Base UI's API. A Radix version you already have won't work with it.
Last updated on