Blocks

Pricing 55

Pricing
4 ColumnsText Align CenterPricing SectionPricing Comparison Section
Pricing 55

Code

relume-pricing55.tsx
import clsx from "clsx";
import { Button, type ButtonProps } from "@/components/ui/button";
import { Check } from "relume-icons";

type Feature = {
  text: string;
  items: React.ReactNode[];
};

type FeatureCategory = {
  title?: string;
  features: Feature[];
};

type PricingPlan = {
  planName: string;
  monthlyPrice: string;
  description: string;
  button: ButtonProps;
};

type Props = {
  tagline: string;
  heading: string;
  description: string;
  pricingPlans: PricingPlan[];
  featureCategories: FeatureCategory[];
  buttons: ButtonProps[];
};

export type Pricing55Props = React.ComponentPropsWithoutRef<"section"> & Partial<Props>;

export const Pricing55 = (props: Pricing55Props) => {
  const { tagline, heading, description, pricingPlans, featureCategories, buttons } = {
    ...Pricing55Defaults,
    ...props,
  };
  return (
    <section className="px-[5%]">
      <div className="container">
        <div className="py-16 md:py-24 lg:py-28">
          <div className="mx-auto mb-12 max-w-lg text-center md:mb-18 lg:mb-20">
            <p className="mb-3 font-semibold md:mb-4">{tagline}</p>
            <h1 className="mb-5 text-h2 font-bold md:mb-6">{heading}</h1>
            <p className="text-medium">{description}</p>
          </div>
          <div className="w-full">
            <div className="grid grid-cols-4 gap-x-4 bg-scheme-background md:grid-cols-[1.5fr_1fr_1fr_1fr_1fr] lg:gap-x-8">
              <div className="hidden md:block" />
              {pricingPlans.map((plan, index) => (
                <PricingPlan key={index} {...plan} />
              ))}
            </div>
            <FeaturesSection featureCategories={featureCategories} />
            <div className="mt-8 grid grid-cols-4 gap-x-4 bg-scheme-background md:grid-cols-[1.5fr_1fr_1fr_1fr_1fr] lg:gap-x-8">
              <div className="hidden md:block" />
              {buttons.map((button, index) => (
                <Button
                  key={index}
                  {...button}
                  className="hidden w-full px-3 py-1 whitespace-normal sm:px-5 sm:py-2 md:flex"
                >
                  {button.title}
                </Button>
              ))}
            </div>
          </div>
        </div>
      </div>
    </section>
  );
};

const PricingPlan = ({ planName, monthlyPrice, description, button }: PricingPlan) => {
  return (
    <div className="flex h-full flex-col justify-between text-center">
      <div className="wrap-anywhere">
        <h2 className="text-base leading-[1.4] font-bold sm:text-lg md:text-xl">{planName}</h2>
        <div className="my-3 md:my-4">
          <h1 className="text-lg leading-[1.2] font-bold md:text-[2rem] lg:text-5xl">
            {monthlyPrice}
            <span className="text-medium">/mo</span>
          </h1>
        </div>
        <p>{description}</p>
      </div>
      <div className="mt-5 hidden md:mt-6 md:block">
        <Button {...button} className="w-full px-3 py-1 whitespace-normal sm:px-5 sm:py-2">
          {button.title}
        </Button>
      </div>
    </div>
  );
};

const FeaturesSection = ({ featureCategories }: { featureCategories: FeatureCategory[] }) => {
  return (
    <div>
      {featureCategories.map((featureCategory, index) => (
        <div key={index}>
          {featureCategory.title && (
            <h3 className="mt-8 py-5 text-h6 font-bold">{featureCategory.title}</h3>
          )}
          {featureCategory.features.map((feature, index) => (
            <div
              key={index}
              className={clsx("grid grid-cols-4 md:grid-cols-[1.5fr_1fr_1fr_1fr_1fr]", {
                "bg-scheme-foreground": index % 2 === 0,
              })}
            >
              <p className="col-span-4 row-span-1 p-4 md:col-span-1 md:px-6 md:py-4">
                {feature.text}
              </p>
              {feature.items.map((item, index) => (
                <p
                  key={index}
                  className="flex items-center justify-center p-4 text-center font-semibold md:px-6"
                >
                  {item}
                </p>
              ))}
            </div>
          ))}
        </div>
      ))}
    </div>
  );
};

export const Pricing55Defaults: Props = {
  tagline: "Tagline",
  heading: "Pricing plan",
  description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
  pricingPlans: [
    {
      planName: "Free",
      monthlyPrice: "$0",
      description: "Lorem ipsum dolor sit amet",
      button: {
        title: "Get started",
        size: "sm",
      },
    },
    {
      planName: "Basic",
      monthlyPrice: "$19",
      description: "Lorem ipsum dolor sit amet",
      button: {
        title: "Get started",
        size: "sm",
      },
    },
    {
      planName: "Business",
      monthlyPrice: "$29",
      description: "Lorem ipsum dolor sit amet",
      button: {
        title: "Get started",
        size: "sm",
      },
    },
    {
      planName: "Enterprise",
      monthlyPrice: "$49",
      description: "Lorem ipsum dolor sit amet",
      button: {
        title: "Get started",
        size: "sm",
      },
    },
  ],
  featureCategories: [
    {
      title: "Feature Category",
      features: [
        {
          text: "Feature text goes here",
          items: ["10", "10", "25", "Unlimited"],
        },
        {
          text: "Feature text goes here",
          items: [
            <Check className="size-6 text-scheme-text" />,
            <Check className="size-6 text-scheme-text" />,
            <Check className="size-6 text-scheme-text" />,
            <Check className="size-6 text-scheme-text" />,
          ],
        },
        {
          text: "Feature text goes here",
          items: [
            <Check className="size-6 text-scheme-text" />,
            <Check className="size-6 text-scheme-text" />,
            <Check className="size-6 text-scheme-text" />,
            <Check className="size-6 text-scheme-text" />,
          ],
        },
        {
          text: "Feature text goes here",
          items: [
            "",
            "",
            <Check className="size-6 text-scheme-text" />,
            <Check className="size-6 text-scheme-text" />,
          ],
        },
        {
          text: "Feature text goes here",
          items: ["", "", "", <Check className="size-6 text-scheme-text" />],
        },
      ],
    },

    {
      title: "Feature Category",
      features: [
        {
          text: "Feature text goes here",
          items: ["10", "10", "25", "Unlimited"],
        },
        {
          text: "Feature text goes here",
          items: [
            <Check className="size-6 text-scheme-text" />,
            <Check className="size-6 text-scheme-text" />,
            <Check className="size-6 text-scheme-text" />,
            <Check className="size-6 text-scheme-text" />,
          ],
        },
        {
          text: "Feature text goes here",
          items: [
            <Check className="size-6 text-scheme-text" />,
            <Check className="size-6 text-scheme-text" />,
            <Check className="size-6 text-scheme-text" />,
            <Check className="size-6 text-scheme-text" />,
          ],
        },
        {
          text: "Feature text goes here",
          items: [
            "",
            "",
            <Check className="size-6 text-scheme-text" />,
            <Check className="size-6 text-scheme-text" />,
          ],
        },
        {
          text: "Feature text goes here",
          items: ["", "", "", <Check className="size-6 text-scheme-text" />],
        },
      ],
    },

    {
      title: "Feature Category",
      features: [
        {
          text: "Feature text goes here",
          items: ["10", "10", "25", "Unlimited"],
        },
        {
          text: "Feature text goes here",
          items: [
            <Check className="size-6 text-scheme-text" />,
            <Check className="size-6 text-scheme-text" />,
            <Check className="size-6 text-scheme-text" />,
            <Check className="size-6 text-scheme-text" />,
          ],
        },
        {
          text: "Feature text goes here",
          items: [
            <Check className="size-6 text-scheme-text" />,
            <Check className="size-6 text-scheme-text" />,
            <Check className="size-6 text-scheme-text" />,
            <Check className="size-6 text-scheme-text" />,
          ],
        },
        {
          text: "Feature text goes here",
          items: [
            "",
            "",
            <Check className="size-6 text-scheme-text" />,
            <Check className="size-6 text-scheme-text" />,
          ],
        },
        {
          text: "Feature text goes here",
          items: ["", "", "", <Check className="size-6 text-scheme-text" />],
        },
      ],
    },
  ],
  buttons: [
    {
      title: "Get started",
      size: "sm",
    },
    {
      title: "Get started",
      size: "sm",
    },
    {
      title: "Get started",
      size: "sm",
    },
    {
      title: "Get started",
      size: "sm",
    },
  ],
};

npm i @radix-ui/react-slot @radix-ui/react-tabs class-variance-authority@0.7.1 clsx@^2.1.1 relume-icons@1.3.0 tailwind-merge@^2.2.2