Skip to content

Pricing tiers

Three plans with concrete limits and one highlighted, monthly or yearly.

108 lines · React · Tailwind 4

Install

$ bunx shadcn@latest add @blocco/pricing-tiers

Code

blocks/free/pricing-tiers.tsx108 lines
import { useState } from "react";
import { Segmented } from "@/registry/blocco/ui/segmented";
import { buttonClass } from "@/registry/blocco/ui/button-class";
import { Check } from "@/registry/blocco/ui/icons";
import { cn } from "@/registry/blocco/ui/cn";

type Billing = "monthly" | "yearly";

const plans = [
  {
    name: "Free",
    monthly: 0,
    yearly: 0,
    blurb: "For trying it on a real campaign.",
    limits: ["30 links", "1,000 clicks a month", "30 days of analytics", "1 member"],
    cta: "Start free",
  },
  {
    name: "Hobby",
    monthly: 6,
    yearly: 60,
    blurb: "For a side project with its own domain.",
    limits: ["500 links", "25,000 clicks a month", "1 custom domain", "1 year of analytics"],
    cta: "Choose Hobby",
    featured: true,
  },
  {
    name: "Pro",
    monthly: 19,
    yearly: 190,
    blurb: "For a team that links everywhere.",
    limits: ["Unlimited links", "250,000 clicks a month", "5 custom domains", "10 members"],
    cta: "Choose Pro",
  },
];

/** Three plans with concrete limits and one highlighted, monthly or yearly. */
export default function PricingTiers() {
  const [billing, setBilling] = useState<Billing>("monthly");
  return (
    <section id="pricing" className="mx-auto max-w-6xl px-6 py-16 sm:py-24">
      <div className="flex flex-col items-center text-center">
        <h2 className="text-3xl font-bold tracking-tight text-balance sm:text-5xl">
          Pick a plan. <span className="text-muted">Change it any time.</span>
        </h2>
        <div className="mt-8">
          <Segmented
            label="Billing"
            value={billing}
            onChange={setBilling}
            items={[
              { id: "monthly", label: "Monthly" },
              { id: "yearly", label: "Yearly, 2 months free" },
            ]}
          />
        </div>
      </div>

      <ul className="mt-12 grid gap-5 lg:grid-cols-3">
        {plans.map((plan) => {
          const price = billing === "monthly" ? plan.monthly : plan.yearly;
          return (
            <li
              key={plan.name}
              className={cn(
                "flex flex-col rounded-2xl bg-surface p-6 smooth-shadow-ring-xs",
                plan.featured && "outline-2 outline-accent",
              )}
            >
              <div className="flex items-center justify-between">
                <h3 className="text-lg font-semibold">{plan.name}</h3>
                {plan.featured && <span className="text-sm text-accent">Most chosen</span>}
              </div>
              <p className="mt-1 text-sm text-muted">{plan.blurb}</p>
              <p className="mt-6 flex items-baseline gap-1.5">
                <span className="tnum text-4xl font-bold tracking-tight">€{price}</span>
                <span className="text-sm text-muted">
                  {price === 0 ? "forever" : billing === "monthly" ? "a month" : "a year"}
                </span>
              </p>
              <ul className="mt-6 grid gap-2.5 text-sm">
                {plan.limits.map((limit) => (
                  <li key={limit} className="flex items-center gap-2.5">
                    <Check size={16} className="shrink-0 text-mint" aria-hidden />
                    {limit}
                  </li>
                ))}
              </ul>
              <a
                href="#"
                className={buttonClass({
                  variant: plan.featured ? "primary" : "outline",
                  className: "mt-8 h-11 w-full justify-center",
                })}
              >
                {plan.cta}
              </a>
            </li>
          );
        })}
      </ul>
      <p className="mt-8 text-center text-sm text-muted">
        Prices include VAT. Cancel from the billing page in one click.
      </p>
    </section>
  );
}