Blocks

Gallery 12

standard
2 ColumnsText Align CenterImage LightboxMultiple ImagesImageGallery Section
Gallery 12

Code

relume-gallery12.tsx
import { cn } from "@/lib/utils";

type ImageProps = {
  url?: string;
  src: string;
  alt?: string;
};

type Props = {
  heading: string;
  description: string;
  images: ImageProps[];
};

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

export const Gallery12 = (props: Gallery12Props) => {
  const { heading, description, images } = {
    ...Gallery12Defaults,
    ...props,
  };
  return (
    <section className="px-[5%] py-16 md:py-24 lg:py-28">
      <div className="container">
        <div className="mb-12 text-center md:mb-18 lg:mb-20">
          <h2 className="mb-5 text-h2 font-bold md:mb-6">{heading}</h2>
          <p className="text-medium">{description}</p>
        </div>
        <div className="grid grid-cols-1 items-start justify-center md:grid-cols-2">
          {images.map((image, index) => (
            <a key={index} href={image.url}>
              <img
                src={image.src}
                alt={image.alt}
                className={cn(
                  "size-full object-cover",
                  index === 0 && "rounded-tl-image",
                  index === 1 && "rounded-tr-image",
                  index === 2 && "rounded-bl-image",
                  index === 3 && "rounded-br-image",
                )}
              />
            </a>
          ))}
        </div>
      </div>
    </section>
  );
};

export const Gallery12Defaults: Props = {
  heading: "Image Gallery",
  description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
  images: [
    {
      url: "#",
      src: "https://d22po4pjz3o32e.cloudfront.net/placeholder-image.svg",
      alt: "Relume placeholder image 1",
    },
    {
      url: "#",
      src: "https://d22po4pjz3o32e.cloudfront.net/placeholder-image.svg",
      alt: "Relume placeholder image 2",
    },
    {
      url: "#",
      src: "https://d22po4pjz3o32e.cloudfront.net/placeholder-image.svg",
      alt: "Relume placeholder image 3",
    },
    {
      url: "#",
      src: "https://d22po4pjz3o32e.cloudfront.net/placeholder-image.svg",
      alt: "Relume placeholder image 4",
    },
  ],
};

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