Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Pricing sections

3 examples. Resize any preview to see it at phone and tablet widths.

Pricing Plans

Free

Three tiers with a monthly/yearly switch that rolls the prices, a per-seat stepper on the team plan, and an expandable feature comparison table.

Hide code
components/blocks/pricing-plans.tsx
"use client";

import { Fragment, useState } from "react";
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
import { ArrowRight, Check, ChevronDown, Minus, Plus } from "lucide-react";
import { cn } from "@/lib/utils";

type Cycle = "monthly" | "yearly";

const tiers = [
  {
    id: "starter",
    name: "Starter",
    blurb: "For side projects and first customers.",
    price: { monthly: 0, yearly: 0 },
    cta: "Start free",
    features: ["1 project", "1,000 monthly events", "Community support", "7-day history"],
  },
  {
    id: "pro",
    name: "Pro",
    blurb: "For founders charging real money.",
    price: { monthly: 24, yearly: 19 },
    cta: "Start 14-day trial",
    featured: true,
    features: ["Unlimited projects", "100k monthly events", "Custom domain", "Email support, 1 business day", "1-year history"],
  },
  {
    id: "team",
    name: "Team",
    blurb: "For small teams shipping together.",
    price: { monthly: 59, yearly: 49 },
    perSeat: true,
    cta: "Start 14-day trial",
    features: ["Everything in Pro", "1M monthly events", "Roles and audit log", "SAML SSO", "Priority support"],
  },
] as const;

const matrix: { group: string; rows: [string, (string | boolean)[]][] }[] = [
  {
    group: "Usage",
    rows: [
      ["Projects", ["1", "Unlimited", "Unlimited"]],
      ["Monthly events", ["1,000", "100k", "1M"]],
      ["Data history", ["7 days", "1 year", "Unlimited"]],
    ],
  },
  {
    group: "Product",
    rows: [
      ["Custom domain", [false, true, true]],
      ["Webhooks", [false, true, true]],
      ["Roles and permissions", [false, false, true]],
      ["Audit log", [false, false, true]],
    ],
  },
  {
    group: "Support",
    rows: [
      ["Community", [true, true, true]],
      ["Email", [false, "1 business day", "4 hours"]],
      ["SAML SSO", [false, false, true]],
    ],
  },
];

function Digits({ value }: { value: number }) {
  const reduce = useReducedMotion();
  const chars = String(value).split("");
  return (
    <span className="inline-flex overflow-hidden tabular-nums" aria-hidden>
      {chars.map((c, i) => (
        <span key={`${chars.length}-${i}`} className="relative inline-block">
          <AnimatePresence mode="popLayout" initial={false}>
            <motion.span
              key={c}
              className="inline-block"
              initial={reduce ? { opacity: 0 } : { y: "60%", opacity: 0, filter: "blur(4px)" }}
              animate={{ y: 0, opacity: 1, filter: "blur(0px)" }}
              exit={reduce ? { opacity: 0 } : { y: "-60%", opacity: 0, filter: "blur(4px)" }}
              transition={{ type: "spring", stiffness: 420, damping: 34, delay: i * 0.03 }}
            >
              {c}
            </motion.span>
          </AnimatePresence>
        </span>
      ))}
    </span>
  );
}

function Toggle({ cycle, onChange }: { cycle: Cycle; onChange: (c: Cycle) => void }) {
  return (
    <div role="radiogroup" aria-label="Billing period" className="relative inline-flex rounded-lg border border-border bg-muted/60 p-1 shadow-[inset_0_1px_2px_rgb(0_0_0/0.06)]">
      {(["monthly", "yearly"] as const).map((c) => (
        <button
          key={c}
          type="button"
          role="radio"
          aria-checked={cycle === c}
          onClick={() => onChange(c)}
          onKeyDown={(e) => {
            if (e.key === "ArrowRight" || e.key === "ArrowLeft") {
              e.preventDefault();
              const next = c === "monthly" ? "yearly" : "monthly";
              onChange(next);
              (e.currentTarget.parentElement?.querySelector(`[data-cycle="${next}"]`) as HTMLButtonElement | null)?.focus();
            }
          }}
          tabIndex={cycle === c ? 0 : -1}
          data-cycle={c}
          className={cn("relative z-10 flex h-8 items-center gap-2 rounded-md px-3.5 text-[13px] font-medium capitalize outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring", cycle === c ? "text-foreground" : "text-muted-foreground hover:text-foreground")}
        >
          {cycle === c ? (
            <motion.span layoutId="pricing-cycle" transition={{ type: "spring", stiffness: 500, damping: 38 }} className="absolute inset-0 -z-10 rounded-md bg-background shadow-[inset_0_1px_0_rgb(255_255_255/0.06),0_0_0_1px_rgb(0_0_0/0.04),0_1px_2px_rgb(0_0_0/0.08),0_3px_8px_-4px_rgb(0_0_0/0.18)]" />
          ) : null}
          {c}
          {c === "yearly" ? <span className="rounded-[4px] bg-emerald-500/12 px-1.5 py-0.5 text-[10px] font-semibold text-emerald-700 dark:text-emerald-400">−20%</span> : null}
        </button>
      ))}
    </div>
  );
}

function Seats({ value, onChange }: { value: number; onChange: (n: number) => void }) {
  const step = "grid size-7 place-items-center rounded-md text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-40";
  return (
    <div className="flex items-center justify-between rounded-md border border-border bg-background/60 py-1 pl-3 pr-1 text-[13px]">
      <span id="seat-label" className="text-muted-foreground">Seats</span>
      <div className="flex items-center gap-1" role="group" aria-labelledby="seat-label">
        <button type="button" className={step} aria-label="Remove a seat" disabled={value <= 2} onClick={() => onChange(value - 1)}>
          <Minus className="size-3.5" aria-hidden />
        </button>
        <output aria-live="polite" className="w-7 text-center font-medium tabular-nums">{value}</output>
        <button type="button" className={step} aria-label="Add a seat" disabled={value >= 50} onClick={() => onChange(value + 1)}>
          <Plus className="size-3.5" aria-hidden />
        </button>
      </div>
    </div>
  );
}

function Mark({ v }: { v: string | boolean }) {
  if (v === true) return <Check className="mx-auto size-4 text-foreground" aria-label="Included" />;
  if (v === false) return <Minus className="mx-auto size-4 text-muted-foreground/50" aria-label="Not included" />;
  return <span className="text-foreground">{v}</span>;
}

export default function PricingPlansBlock() {
  const [cycle, setCycle] = useState<Cycle>("yearly");
  const [seats, setSeats] = useState(3);
  const [compare, setCompare] = useState(false);

  return (
    <section className="w-full px-4 py-16 sm:px-6 sm:py-20">
      <div className="mx-auto max-w-5xl">
        <div className="flex flex-col items-center text-center">
          <p className="font-mono text-[11px] uppercase tracking-[0.14em] text-muted-foreground">Pricing</p>
          <h2 className="mt-3 max-w-xl text-balance text-3xl font-semibold tracking-tight sm:text-4xl">Pay for what you use, not for a sales call.</h2>
          <p className="mt-3 max-w-md text-pretty text-muted-foreground">Every plan includes the full product. Upgrade when you outgrow the limits.</p>
          <div className="mt-8"><Toggle cycle={cycle} onChange={setCycle} /></div>
        </div>

        <div className="mt-10 grid gap-3 md:grid-cols-3 md:gap-4">
          {tiers.map((t) => {
            const unit = t.price[cycle];
            const total = "perSeat" in t ? unit * seats : unit;
            const featured = "featured" in t && t.featured;
            return (
              <div
                key={t.id}
                className={cn(
                  "group relative flex flex-col rounded-xl border p-6 transition-[translate,box-shadow,border-color] duration-300 ease-[cubic-bezier(0.22,1,0.36,1)] hover:-translate-y-0.5 motion-reduce:hover:translate-y-0",
                  featured
                    ? "border-foreground/20 bg-card shadow-[inset_0_1px_0_rgb(255_255_255/0.06),0_0_0_1px_rgb(0_0_0/0.03),0_2px_4px_-2px_rgb(0_0_0/0.1),0_28px_56px_-28px_rgb(0_0_0/0.4)] md:-my-3 md:py-9"
                    : "border-border bg-card/60 shadow-[inset_0_1px_0_rgb(255_255_255/0.04),0_1px_2px_rgb(0_0_0/0.04)] hover:shadow-[inset_0_1px_0_rgb(255_255_255/0.04),0_1px_2px_rgb(0_0_0/0.05),0_18px_36px_-24px_rgb(0_0_0/0.3)]",
                )}
              >
                {featured ? (
                  <>
                    <div aria-hidden className="pointer-events-none absolute inset-x-6 -top-px h-px bg-gradient-to-r from-transparent via-foreground/50 to-transparent" />
                    <span className="absolute right-4 top-4 rounded-[4px] bg-foreground px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wider text-background">Most picked</span>
                  </>
                ) : null}
                <h3 className="text-sm font-semibold">{t.name}</h3>
                <p className="mt-1 text-[13px] text-muted-foreground">{t.blurb}</p>
                <div className="mt-6 flex items-baseline gap-1">
                  <span className="text-4xl font-semibold tracking-tight">
                    <span className="sr-only">${total} per month</span>$<Digits value={total} />
                  </span>
                  <span className="text-[13px] text-muted-foreground">/mo</span>
                </div>
                <p className="mt-1 h-4 text-xs text-muted-foreground">
                  {unit === 0 ? "Free forever" : cycle === "yearly" ? `Billed $${total * 12} yearly` : "Billed monthly"}
                  {"perSeat" in t ? ` · $${unit}/seat` : ""}
                </p>
                {"perSeat" in t ? <div className="mt-4"><Seats value={seats} onChange={setSeats} /></div> : null}
                <a
                  href={`#${t.id}`}
                  className={cn(
                    "group/cta mt-6 inline-flex h-10 items-center justify-center gap-1.5 rounded-md text-sm font-medium outline-none transition-[background-color,scale,box-shadow] focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background active:scale-[0.985]",
                    featured
                      ? "bg-foreground text-background shadow-[inset_0_1px_0_rgb(255_255_255/0.18),0_1px_2px_rgb(0_0_0/0.24),0_6px_14px_-8px_rgb(0_0_0/0.5)] hover:bg-foreground/90"
                      : "border border-border bg-background shadow-[0_1px_2px_rgb(0_0_0/0.05)] hover:bg-muted active:shadow-[inset_0_1px_2px_rgb(0_0_0/0.1)]",
                  )}
                >
                  {t.cta}
                  <ArrowRight className="size-4 transition-transform duration-200 group-hover/cta:translate-x-0.5" aria-hidden />
                </a>
                <ul className="mt-6 space-y-2.5 border-t border-dashed border-border pt-6 text-[13px]">
                  {t.features.map((f) => (
                    <li key={f} className="flex items-start gap-2.5">
                      <span className={cn("mt-0.5 grid size-4 shrink-0 place-items-center rounded-[4px]", featured ? "bg-foreground text-background" : "bg-muted text-foreground")}>
                        <Check className="size-3" strokeWidth={3} aria-hidden />
                      </span>
                      {f}
                    </li>
                  ))}
                </ul>
              </div>
            );
          })}
        </div>

        <div className="mt-10 flex justify-center">
          <button
            type="button"
            aria-expanded={compare}
            aria-controls="pricing-compare"
            onClick={() => setCompare((v) => !v)}
            className="inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-[13px] font-medium text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring"
          >
            {compare ? "Hide" : "Compare all"} features
            <ChevronDown className={cn("size-4 transition-transform duration-300", compare && "rotate-180")} aria-hidden />
          </button>
        </div>

        <AnimatePresence initial={false}>
          {compare ? (
            <motion.div
              id="pricing-compare"
              initial={{ height: 0, opacity: 0 }}
              animate={{ height: "auto", opacity: 1 }}
              exit={{ height: 0, opacity: 0 }}
              transition={{ duration: 0.35, ease: [0.22, 1, 0.36, 1] }}
              className="overflow-hidden"
            >
              <div className="relative mt-6 overflow-x-auto rounded-xl border border-border bg-card">
                <table className="w-full min-w-[560px] text-[13px]">
                  <caption className="sr-only">Plan comparison</caption>
                  <thead>
                    <tr className="border-b border-border">
                      <th scope="col" className="sticky left-0 bg-card px-4 py-3 text-left font-medium text-muted-foreground">Feature</th>
                      {tiers.map((t) => (
                        <th key={t.id} scope="col" className={cn("px-4 py-3 text-center font-semibold", "featured" in t && "bg-muted/50")}>{t.name}</th>
                      ))}
                    </tr>
                  </thead>
                  <tbody>
                    {matrix.map((g) => (
                      <Fragment key={g.group}>
                        <tr>
                          <th colSpan={4} scope="colgroup" className="bg-muted/30 px-4 pb-2 pt-4 text-left font-mono text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground">{g.group}</th>
                        </tr>
                        {g.rows.map(([label, vals]) => (
                          <tr key={label} className="border-t border-border/60 transition-colors hover:bg-muted/30">
                            <th scope="row" className="sticky left-0 bg-card px-4 py-2.5 text-left font-normal">{label}</th>
                            {vals.map((v, i) => (
                              <td key={i} className={cn("px-4 py-2.5 text-center text-muted-foreground", i === 1 && "bg-muted/50")}><Mark v={v} /></td>
                            ))}
                          </tr>
                        ))}
                      </Fragment>
                    ))}
                  </tbody>
                </table>
              </div>
            </motion.div>
          ) : null}
        </AnimatePresence>
      </div>
    </section>
  );
}

Usage Calculator

Free

A metered API plan with an adjustable request volume, itemized usage and monthly estimate.

Plan Comparison

Pro

A feature-by-feature plan table with grouped rows, a highlighted plan and a feature column that stays in view while the table scrolls sideways on phones.

The source for this block is part of Truffle Pro.