Blocks

CTA 57

standard
1 ColumnText Align CenterButtonsText OnlyCTA Section
CTA 57

Code

relume-cta57.tsx
"use client";

import { useRef } from "react";
import { motion } from "motion/react";
import clsx from "clsx";
import { Button, type ButtonProps } from "@/components/ui/button";

type Props = {
  headers: string[];
  description: string;
  buttons: ButtonProps[];
};

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

export const Cta57 = (props: Cta57Props) => {
  const sectionRef = useRef<HTMLElement>(null);

  const { headers, description, buttons } = {
    ...Cta57Defaults,
    ...props,
  };
  return (
    <section ref={sectionRef} className="px-[5%] py-16 md:py-24 lg:py-28">
      <div className="container">
        <div className="mx-auto w-full max-w-lg text-center">
          <h1>
            {headers.map((heading, index) => (
              <motion.span
                key={index}
                initial={{ x: index % 2 === 0 ? "-50%" : "50%", opacity: 0 }}
                whileInView={{ x: "0%", opacity: 1 }}
                viewport={{ once: true }}
                transition={{
                  type: "spring",
                  bounce: 0,
                  duration: 0.5,
                  delay: index * 0.2,
                }}
                className={clsx("block text-h1 font-bold", {
                  "mb-5 md:mb-6": index !== 0,
                })}
              >
                {heading}
              </motion.span>
            ))}
          </h1>
          <p className="text-medium">{description}</p>
          <div className="mt-6 flex items-center justify-center gap-x-4 md:mt-8">
            {buttons.map((button, index) => (
              <Button key={index} {...button}>
                {button.title}
              </Button>
            ))}
          </div>
        </div>
      </div>
    </section>
  );
};

export const Cta57Defaults: Props = {
  headers: ["Medium length CTA", "heading goes here"],
  description:
    "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique.",
  buttons: [{ title: "Button" }, { title: "Button", variant: "secondary" }],
};

npm i @radix-ui/react-slot 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