Blocks

Pricing 42

Pricing
3 ColumnsText Align LeftTabsPricing Section
Pricing 42

Code

relume-pricing42.tsx
import { Check, RelumeIcon } from "relume-icons";

import { Button, type ButtonProps } from "@/components/ui/button";
import { Card } from "@/components/ui/card";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";

type Billing = "monthly" | "yearly";

type Feature = {
  icon: React.ReactNode;
  text: string;
};

type PricingPlan = {
  planName: string;
  price: string;
  discount?: string;
  features: Feature[];
  button: ButtonProps;
};

type Tab = {
  value: Billing;
  tabName: string;
  plans: PricingPlan[];
};

type Props = {
  tagline: string;
  heading: string;
  description: string;
  defaultTabValue: Billing;
  tabs: Tab[];
};

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

export const Pricing42 = (props: Pricing42Props) => {
  const { tagline, heading, description, defaultTabValue, tabs } = {
    ...Pricing42Defaults,
    ...props,
  };
  return (
    <section className="px-[5%] py-16 md:py-24 lg:py-28">
      <div className="container">
        <Tabs defaultValue={defaultTabValue}>
          <div className="grid grid-cols-1 items-end justify-between lg:grid-cols-2 lg:gap-x-12">
            <div className="mb-12 max-w-lg 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>
            <TabsList className="mb-12 w-fit items-center rounded-button border bg-scheme-foreground p-1 group-data-[slot=card-flat]:border-transparent lg:mb-20 lg:justify-self-end">
              {tabs.map((tab, index) => (
                <TabsTrigger
                  key={index}
                  value={tab.value}
                  className="rounded-button data-[state=active]:bg-scheme-background data-[state=active]:font-medium data-[state=inactive]:bg-transparent"
                >
                  {tab.tabName}
                </TabsTrigger>
              ))}
            </TabsList>
          </div>
          {tabs.map((tab, index) => (
            <TabsContent key={index} value={tab.value} className="data-[state=active]:animate-tabs">
              <div className="grid grid-cols-1 gap-8 lg:grid-cols-3">
                {tab.plans.map((plan, planIndex) => (
                  <PricingPlan key={planIndex} plan={plan} billing={tab.value} />
                ))}
              </div>
            </TabsContent>
          ))}
        </Tabs>
      </div>
    </section>
  );
};

const PricingPlan = ({ plan, billing }: { plan: PricingPlan; billing: Billing }) => (
  <Card className="flex h-full flex-col justify-between px-6 py-8 md:p-8">
    <div>
      <div className="flex items-start justify-between">
        <h6 className="text-h6 font-bold">{plan.planName}</h6>
        <RelumeIcon className="size-12 text-scheme-text" />
      </div>
      <h3 className="mb-2 text-h1 font-bold">
        {plan.price}
        <span className="inline text-h4 font-bold">{billing === "monthly" ? "/mo" : "/yr"}</span>
      </h3>
      {billing === "yearly" && plan.discount && <p className="font-medium">{plan.discount}</p>}
      <div className="my-6 h-px w-full shrink-0 bg-scheme-border md:my-8" />
      <p>Includes:</p>
      <div className="mt-3 grid grid-cols-1 gap-y-4 py-2 md:mt-4">
        {plan.features.map((feature, index) => (
          <div key={index} className="flex self-start">
            <div className="mr-4 flex-none self-start">{feature.icon}</div>
            <p>{feature.text}</p>
          </div>
        ))}
      </div>
    </div>
    <div className="mt-6 md:mt-8">
      <Button {...plan.button} className="w-full">
        {plan.button.title}
      </Button>
    </div>
  </Card>
);

export const Pricing42Defaults: Props = {
  tagline: "Tagline",
  heading: "Pricing plan",
  description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
  defaultTabValue: "monthly",
  tabs: [
    {
      value: "monthly",
      tabName: "Monthly",
      plans: [
        {
          planName: "Basic plan",
          price: "$19",
          features: [
            { icon: <Check className="size-6 text-scheme-text" />, text: "Feature text goes here" },
            { icon: <Check className="size-6 text-scheme-text" />, text: "Feature text goes here" },
            { icon: <Check className="size-6 text-scheme-text" />, text: "Feature text goes here" },
          ],
          button: { title: "Get started" },
        },
        {
          planName: "Business plan",
          price: "$29",
          features: [
            { icon: <Check className="size-6 text-scheme-text" />, text: "Feature text goes here" },
            { icon: <Check className="size-6 text-scheme-text" />, text: "Feature text goes here" },
            { icon: <Check className="size-6 text-scheme-text" />, text: "Feature text goes here" },
            { icon: <Check className="size-6 text-scheme-text" />, text: "Feature text goes here" },
          ],
          button: { title: "Get started" },
        },
        {
          planName: "Enterprise plan",
          price: "$49",
          features: [
            { icon: <Check className="size-6 text-scheme-text" />, text: "Feature text goes here" },
            { icon: <Check className="size-6 text-scheme-text" />, text: "Feature text goes here" },
            { icon: <Check className="size-6 text-scheme-text" />, text: "Feature text goes here" },
            { icon: <Check className="size-6 text-scheme-text" />, text: "Feature text goes here" },
            { icon: <Check className="size-6 text-scheme-text" />, text: "Feature text goes here" },
          ],
          button: { title: "Get started" },
        },
      ],
    },
    {
      value: "yearly",
      tabName: "Yearly",
      plans: [
        {
          planName: "Basic plan",
          price: "$180",
          discount: "Save 20%",
          features: [
            { icon: <Check className="size-6 text-scheme-text" />, text: "Feature text goes here" },
            { icon: <Check className="size-6 text-scheme-text" />, text: "Feature text goes here" },
            { icon: <Check className="size-6 text-scheme-text" />, text: "Feature text goes here" },
          ],
          button: { title: "Get started" },
        },
        {
          planName: "Business plan",
          price: "$280",
          discount: "Save 20%",
          features: [
            { icon: <Check className="size-6 text-scheme-text" />, text: "Feature text goes here" },
            { icon: <Check className="size-6 text-scheme-text" />, text: "Feature text goes here" },
            { icon: <Check className="size-6 text-scheme-text" />, text: "Feature text goes here" },
            { icon: <Check className="size-6 text-scheme-text" />, text: "Feature text goes here" },
          ],
          button: { title: "Get started" },
        },
        {
          planName: "Enterprise plan",
          price: "$480",
          discount: "Save 20%",
          features: [
            { icon: <Check className="size-6 text-scheme-text" />, text: "Feature text goes here" },
            { icon: <Check className="size-6 text-scheme-text" />, text: "Feature text goes here" },
            { icon: <Check className="size-6 text-scheme-text" />, text: "Feature text goes here" },
            { icon: <Check className="size-6 text-scheme-text" />, text: "Feature text goes here" },
            { icon: <Check className="size-6 text-scheme-text" />, text: "Feature text goes here" },
          ],
          button: { title: "Get started" },
        },
      ],
    },
  ],
};

npm i @radix-ui/react-accordion @radix-ui/react-dialog @radix-ui/react-slot @radix-ui/react-tabs class-variance-authority@0.7.1 clsx@^2.1.1 embla-carousel-react@^8.5.2 motion@^12.15.0 relume-icons@1.3.0 tailwind-merge@^2.2.2