Compute Pricing Calculator
Large rounded panel with a washed top gradient: left plan selector with a small Pro/Team segmented toggle and check list, right an estimate summary and project card with a tick-mark slider, mono 'MICRO' tag and an emerald Add Project button. Below, a spec table with muted header row, highlighted first row and a bottom fade with a 'Show pricing breakdown' pill.
Rebuilt from supabase.com/pricing in the Emerald Paper Precision style.
Looks exactly like supabase.com: brings its fonts and colours, namespaced so your own theme stays untouched.
Restyled to your project: uses your shadcn colours, fonts and radius, so it matches the rest of your app. Layout, type sizes and motion stay as designed.
Usage
Renders standalone; optional props `heading` and `subheading` change the section title. Drag the tick slider to pick a size, switch tiers with the toggle, and expand the table with the pill button.
components/compute-pricing-calculator.tsx
import { useState } from "react"; const SIZES = [ { name: "Nano", price: 8, cpu: "Shared", mem: "512 MB", a: 40, b: 120 }, { name: "Compact", price: 14, cpu: "Shared", mem: "1 GB", a: 60, b: 200 }, { name: "Medium", price: 28, cpu: "1 vCPU", mem: "4 GB", a: 120, b: 400 }, { name: "Large", price: 56, cpu: "2 vCPU", mem: "8 GB", a: 180, b: 600 }, { name: "Jumbo", price: 112, cpu: "4 vCPU", mem: "16 GB", a: 240, b: 800 }, { name: "Titan", price: 224, cpu: "8 vCPU", mem: "32 GB", a: 320, b: 1000 }, ]; const PLANS = { Starter: { price: 20, perks: ["50K requests per day", "5 GB storage per workspace", "100 GB transfer", "Weekly snapshots (14 day history)", "Chat support"] }, Crew: { price: 80, perks: ["500K requests per day", "50 GB storage per workspace", "1 TB transfer", "Daily snapshots (30 day history)", "Priority support"] }, }; export default function ComputePricingCalculator({ heading = "Estimating your hosting bill", subheading = "Pick a tier, size your workspaces, and preview the monthly total", }: { heading?: string; subheading?: string }) { const [plan, setPlan] = useState<"Starter" | "Crew">("Starter"); const [idx, setIdx] = useState(1); const [open, setOpen] = useState(false); const s = SIZES[idx]; const p = PLANS[plan]; const credit = 8; const total = p.price + Math.max(0, s.price - credit); const rows = open ? SIZES : SIZES.slice(0, 3); return ( <section className="bg-canvas px-4 py-16 font-sans text-ink"> <div className="mx-auto max-w-3xl text-center"> <h2 className="font-display text-h2 tracking-tight">{heading}</h2> <p className="mt-3 text-lead text-ink-soft">{subheading}</p> </div> <div className="relative mx-auto mt-12 max-w-6xl overflow-hidden rounded-xl border border-hairline bg-surface"> <div className="pointer-events-none absolute inset-x-0 top-0 h-3/4 bg-gradient-to-b from-ink/[0.08] to-ink/[0.04] opacity-50" /> <div className="relative grid gap-10 p-6 md:grid-cols-[360px_1fr] md:p-8"> <div> <div className="flex items-center gap-3"> <span className="text-lead text-ink-soft">1. Select a tier</span> <div className="relative grid grid-cols-2 rounded-md bg-surface-muted p-0.5" role="tablist"> <span className={`absolute inset-y-0.5 w-1/2 rounded-xs bg-surface shadow-card-hairline transition-transform duration-base-transition ${plan === "Crew" ? "translate-x-[calc(100%-4px)]" : "translate-x-0"}`} /> {(["Starter", "Crew"] as const).map((n) => ( <button key={n} role="tab" aria-selected={plan === n} onClick={() => setPlan(n)} className="relative z-10 px-3 py-1 text-caption focus-visible:outline focus-visible:outline-2 focus-visible:outline-brand">{n}</button> ))} </div> </div> <h3 className="mt-6 font-display text-h3">{plan}</h3> <p className="mt-3 text-ink-soft"><b className="font-mono text-ink">${p.price}</b>/month</p> <p className="mt-4 text-ink-soft">Everything in Hobby, plus:</p> <ul className="mt-3 space-y-2"> {p.perks.map((t) => ( <li key={t} className="flex items-center gap-2 text-body text-ink-soft"> <span className="grid h-4 w-4 place-items-center rounded-pill bg-brand-tint text-brand-bright"> <svg width="9" height="9" viewBox="0 0 10 10" fill="none" stroke="currentColor" strokeWidth="1.6"><path d="M2 5.2l2 2L8 3" /></svg> </span> {t} </li> ))} </ul> <p className="mt-5 text-caption text-ink-muted">Each paid tier bundles ${credit} of monthly usage allowance, which fully covers the smallest workspace size.</p> </div> <div> <h3 className="text-lead">2. Size your workspaces</h3> <p className="mt-2 text-caption text-ink-muted">Add workspaces and drag the slider to preview what you will pay each month.</p> <div className="mt-5 rounded-lg border border-hairline bg-surface p-4"> <div className="grid gap-4 sm:grid-cols-[170px_1fr]"> <dl className="space-y-2 text-caption text-ink-soft"> <dt className="text-ink">Estimate:</dt> {[["Tier fee", `$${p.price}`], ["Total usage", `$${s.price}`], ["Allowance", `−$${Math.min(credit, s.price)}`]].map(([k, v]) => ( <div key={k} className="flex justify-between"><dt>{k}</dt><dd>{v}</dd></div> ))} <div className="flex justify-between border-t border-hairline pt-2 text-ink"><dt>Total</dt><dd className="font-medium">${total}</dd></div> </dl> <div className="rounded-lg border border-hairline bg-surface-muted p-4"> <div className="flex items-center justify-between"> <span className="flex items-center gap-2 text-caption text-ink-soft">Workspace 1 <span className="rounded-xs border border-hairline-strong px-1 font-mono text-[10px] uppercase">{s.name}</span></span> <span className="text-label">${s.price}</span> </div> <div className="relative mt-4 h-8"> <div className="absolute inset-0 flex items-center justify-between"> {SIZES.map((z, i) => ( <span key={z.name} className={`w-px ${i === idx ? "h-6 bg-ink" : "h-4 bg-hairline-strong"}`} /> ))} </div> <input type="range" min={0} max={SIZES.length - 1} step={1} value={idx} onChange={(e) => setIdx(+e.target.value)} aria-label="Workspace size" className="absolute inset-0 h-full w-full cursor-pointer opacity-0" /> </div> <p className="mt-3 text-caption text-ink-soft">{s.mem} memory / {s.cpu} compute / Links: Direct {s.a}, Pooled {s.b}</p> </div> </div> <div className="mt-3 flex justify-end"> <button className="rounded-md bg-brand px-3 py-1.5 text-caption text-surface transition-colors duration-hover-color ease-hover-color hover:bg-brand-hover focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand">+ Add Workspace</button> </div> </div> </div> </div> <div className="relative px-6 pb-8 md:px-8"> <p className="text-caption text-ink-soft">Starts at $8/month</p> <div className="mt-2 flex flex-wrap items-end justify-between gap-3"> <h3 className="font-display text-h3">Grow from 512 MB<br />to 32 GB of memory</h3> <button className="rounded-md border border-hairline bg-surface px-3 py-1.5 text-caption hover:border-hairline-strong">Read about size add-ons</button> </div> <div className="relative mt-8 overflow-x-auto"> <table className="w-full min-w-[640px] text-left text-caption"> <thead> <tr className="text-ink">{["Size", "Price USD", "Compute", "Memory", "Links: Direct", "Links: Pooled"].map((h) => <th key={h} className="px-3 py-3 font-medium">{h}</th>)}</tr> </thead> <tbody className="text-ink-muted"> {rows.map((r, i) => ( <tr key={r.name} className={i === idx ? "rounded-md bg-surface-muted" : i === 0 ? "bg-surface-muted" : ""}> <td className="px-3 py-2.5">{r.name}</td><td className="px-3">${r.price}</td><td className="px-3">{r.cpu}</td><td className="px-3">{r.mem}</td><td className="px-3">{r.a}</td><td className="px-3">{r.b}</td> </tr> ))} </tbody> </table> {!open && <div className="pointer-events-none absolute inset-x-0 bottom-0 h-24 bg-gradient-to-t from-surface to-transparent" />} </div> <div className={`${open ? "mt-4" : "-mt-6"} relative flex justify-center`}> <button onClick={() => setOpen(!open)} aria-expanded={open} className="rounded-pill border border-hairline bg-surface px-3 py-1 text-caption hover:border-hairline-strong focus-visible:outline focus-visible:outline-2 focus-visible:outline-brand">{open ? "Hide breakdown" : "Show pricing breakdown"}</button> </div> </div> </div> </section> ); }import { useState } from "react"; const SIZES = [ { name: "Nano", price: 8, cpu: "Shared", mem: "512 MB", a: 40, b: 120 }, { name: "Compact", price: 14, cpu: "Shared", mem: "1 GB", a: 60, b: 200 }, { name: "Medium", price: 28, cpu: "1 vCPU", mem: "4 GB", a: 120, b: 400 }, { name: "Large", price: 56, cpu: "2 vCPU", mem: "8 GB", a: 180, b: 600 }, { name: "Jumbo", price: 112, cpu: "4 vCPU", mem: "16 GB", a: 240, b: 800 }, { name: "Titan", price: 224, cpu: "8 vCPU", mem: "32 GB", a: 320, b: 1000 }, ]; const PLANS = { Starter: { price: 20, perks: ["50K requests per day", "5 GB storage per workspace", "100 GB transfer", "Weekly snapshots (14 day history)", "Chat support"] }, Crew: { price: 80, perks: ["500K requests per day", "50 GB storage per workspace", "1 TB transfer", "Daily snapshots (30 day history)", "Priority support"] }, }; export default function ComputePricingCalculator({ heading = "Estimating your hosting bill", subheading = "Pick a tier, size your workspaces, and preview the monthly total", }: { heading?: string; subheading?: string }) { const [plan, setPlan] = useState<"Starter" | "Crew">("Starter"); const [idx, setIdx] = useState(1); const [open, setOpen] = useState(false); const s = SIZES[idx]; const p = PLANS[plan]; const credit = 8; const total = p.price + Math.max(0, s.price - credit); const rows = open ? SIZES : SIZES.slice(0, 3); return ( <section className="bg-background px-4 py-16 font-sans text-foreground"> <div className="mx-auto max-w-3xl text-center"> <h2 className="font-sans text-emerald-h2 tracking-tight">{heading}</h2> <p className="mt-3 text-emerald-lead text-muted-foreground">{subheading}</p> </div> <div className="relative mx-auto mt-12 max-w-6xl overflow-hidden rounded-xl border border-border bg-card"> <div className="pointer-events-none absolute inset-x-0 top-0 h-3/4 bg-gradient-to-b from-foreground/[0.08] to-foreground/[0.04] opacity-50" /> <div className="relative grid gap-10 p-6 md:grid-cols-[360px_1fr] md:p-8"> <div> <div className="flex items-center gap-3"> <span className="text-emerald-lead text-muted-foreground">1. Select a tier</span> <div className="relative grid grid-cols-2 rounded-md bg-muted p-0.5" role="tablist"> <span className={`absolute inset-y-0.5 w-1/2 rounded-md bg-card shadow-emerald-card-hairline transition-transform duration-emerald-base-transition ${plan === "Crew" ? "translate-x-[calc(100%-4px)]" : "translate-x-0"}`} /> {(["Starter", "Crew"] as const).map((n) => ( <button key={n} role="tab" aria-selected={plan === n} onClick={() => setPlan(n)} className="relative z-10 px-3 py-1 text-emerald-caption focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary">{n}</button> ))} </div> </div> <h3 className="mt-6 font-sans text-emerald-h3">{plan}</h3> <p className="mt-3 text-muted-foreground"><b className="font-mono text-foreground">${p.price}</b>/month</p> <p className="mt-4 text-muted-foreground">Everything in Hobby, plus:</p> <ul className="mt-3 space-y-2"> {p.perks.map((t) => ( <li key={t} className="flex items-center gap-2 text-emerald-body text-muted-foreground"> <span className="grid h-4 w-4 place-items-center rounded-full bg-primary/10 text-primary"> <svg width="9" height="9" viewBox="0 0 10 10" fill="none" stroke="currentColor" strokeWidth="1.6"><path d="M2 5.2l2 2L8 3" /></svg> </span> {t} </li> ))} </ul> <p className="mt-5 text-emerald-caption text-muted-foreground">Each paid tier bundles ${credit} of monthly usage allowance, which fully covers the smallest workspace size.</p> </div> <div> <h3 className="text-emerald-lead">2. Size your workspaces</h3> <p className="mt-2 text-emerald-caption text-muted-foreground">Add workspaces and drag the slider to preview what you will pay each month.</p> <div className="mt-5 rounded-lg border border-border bg-card p-4"> <div className="grid gap-4 sm:grid-cols-[170px_1fr]"> <dl className="space-y-2 text-emerald-caption text-muted-foreground"> <dt className="text-foreground">Estimate:</dt> {[["Tier fee", `$${p.price}`], ["Total usage", `$${s.price}`], ["Allowance", `−$${Math.min(credit, s.price)}`]].map(([k, v]) => ( <div key={k} className="flex justify-between"><dt>{k}</dt><dd>{v}</dd></div> ))} <div className="flex justify-between border-t border-border pt-2 text-foreground"><dt>Total</dt><dd className="font-medium">${total}</dd></div> </dl> <div className="rounded-lg border border-border bg-muted p-4"> <div className="flex items-center justify-between"> <span className="flex items-center gap-2 text-emerald-caption text-muted-foreground">Workspace 1 <span className="rounded-md border border-border px-1 font-mono text-[10px] uppercase">{s.name}</span></span> <span className="text-emerald-label">${s.price}</span> </div> <div className="relative mt-4 h-8"> <div className="absolute inset-0 flex items-center justify-between"> {SIZES.map((z, i) => ( <span key={z.name} className={`w-px ${i === idx ? "h-6 bg-foreground" : "h-4 bg-border"}`} /> ))} </div> <input type="range" min={0} max={SIZES.length - 1} step={1} value={idx} onChange={(e) => setIdx(+e.target.value)} aria-label="Workspace size" className="absolute inset-0 h-full w-full cursor-pointer opacity-0" /> </div> <p className="mt-3 text-emerald-caption text-muted-foreground">{s.mem} memory / {s.cpu} compute / Links: Direct {s.a}, Pooled {s.b}</p> </div> </div> <div className="mt-3 flex justify-end"> <button className="rounded-md bg-primary px-3 py-1.5 text-emerald-caption text-card transition-colors duration-emerald-hover-color ease-emerald-hover-color hover:bg-primary/90 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary">+ Add Workspace</button> </div> </div> </div> </div> <div className="relative px-6 pb-8 md:px-8"> <p className="text-emerald-caption text-muted-foreground">Starts at $8/month</p> <div className="mt-2 flex flex-wrap items-end justify-between gap-3"> <h3 className="font-sans text-emerald-h3">Grow from 512 MB<br />to 32 GB of memory</h3> <button className="rounded-md border border-border bg-card px-3 py-1.5 text-emerald-caption hover:border-border">Read about size add-ons</button> </div> <div className="relative mt-8 overflow-x-auto"> <table className="w-full min-w-[640px] text-left text-emerald-caption"> <thead> <tr className="text-foreground">{["Size", "Price USD", "Compute", "Memory", "Links: Direct", "Links: Pooled"].map((h) => <th key={h} className="px-3 py-3 font-medium">{h}</th>)}</tr> </thead> <tbody className="text-muted-foreground"> {rows.map((r, i) => ( <tr key={r.name} className={i === idx ? "rounded-md bg-muted" : i === 0 ? "bg-muted" : ""}> <td className="px-3 py-2.5">{r.name}</td><td className="px-3">${r.price}</td><td className="px-3">{r.cpu}</td><td className="px-3">{r.mem}</td><td className="px-3">{r.a}</td><td className="px-3">{r.b}</td> </tr> ))} </tbody> </table> {!open && <div className="pointer-events-none absolute inset-x-0 bottom-0 h-24 bg-gradient-to-t from-card to-transparent" />} </div> <div className={`${open ? "mt-4" : "-mt-6"} relative flex justify-center`}> <button onClick={() => setOpen(!open)} aria-expanded={open} className="rounded-full border border-border bg-card px-3 py-1 text-emerald-caption hover:border-border focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary">{open ? "Hide breakdown" : "Show pricing breakdown"}</button> </div> </div> </div> </section> ); }
Quality checks
Automated, in a real browser · 4d ago- Accessible: not passed<dl> elements must only directly contain properly-ordered <dt> and <dd> groups, <script>, <template> or <div> elements (1 element)Scrollable region must have keyboard access (1 element)
- Responsive: passedRenders at phone (390px), tablet (768px) and desktop width without sideways scrolling.
- Dark mode: passedStill readable when installed in your theme and switched to dark mode.
- Themeable: passedUses design tokens rather than hard-coded colours, so it follows your theme cleanly.
- Animates cleanly: doesn't applyDoesn't animate, so there's nothing to check.