Footer Forge

Site footer with a tagline, navigation groups, optional contact and legal rows, and a large heated-metal wordmark: steel letters, a static amber heat at the base and a mouse-following hot spot that cools after the pointer leaves. Follows the site theme. CSS and pointer events only, token-only colours.

pnpm dlx shadcn@latest add @leo/footer-forge

Props

NameTypeDefaultDescription
classNamestring | undefined-
contactFooterForgeLink[] | null | undefined[ { label: "hello@forge.studio", href: "mailto:hello@forge.studio" }, { label: "+84 900 000 000", href: "tel:+84900000000" }, ]mailto:, tel: or external links, plain <a>; http(s) ones open in a new tab. `null` hides.
contentClassNamestring | undefined-Merged onto the rows wrapper (tagline, navigation, contact, legal), e.g. `mx-auto max-w-6xl md:px-6` to line it up with the page container. The wordmark stays full width.
copyrightstring | undefined© Forge Studio. All rights reserved.Static text; the block does not compute the year.
groupsFooterForgeGroup[] | undefined[ { links: [ { label: "Services", href: "/services" }, { label: "Projects", href: "/projects" }, { label: "Blog", href: "/blog" }, { label: "About", href: "/about" }, { label: "Contact", href: "/contact" }, ], }, ]Internal navigation, rendered with linkComponent. Omit for the sample.
legalstring[] | null | undefined["Forge Studio Co., Ltd.", "Tax ID 0100000000", "1 Example Street, Hanoi"]Legal identity lines (company, tax ID, address). `null` hides the row.
linkComponentElementType<{ href: string; className?: string | undefined; children?: ReactNode; }, keyof IntrinsicElements> | undefinedaLink element for group links, e.g. next/link. Receives href, className and children.
navLabelstring | undefinedFooterAccessible name of the <nav>.
reducedMotionundefined | "respect" | "ignore"respect"ignore" keeps the mouse hot spot for visitors who prefer reduced motion.
taglinestring | undefinedCustom websites, built to be handed over.
wordmarkstring | undefinedForge StudioLarge wordmark at the bottom, the site's name. Empty string hides it.

Source

"use client";
import { useEffect, useRef } from "react";
import { useForgeMotion } from "@/hooks/use-forge-motion";
import { cn } from "@/lib/utils";

export interface FooterForgeLink {
  label: string;
  href: string;
}

export interface FooterForgeGroup {
  title?: string;
  links: FooterForgeLink[];
}

export interface FooterForgeProps {
  /** Large wordmark at the bottom, the site's name. Empty string hides it. */
  wordmark?: string;
  tagline?: string;
  /** Internal navigation, rendered with linkComponent. Omit for the sample. */
  groups?: FooterForgeGroup[];
  /** mailto:, tel: or external links, plain <a>; http(s) ones open in a new tab. `null` hides. */
  contact?: FooterForgeLink[] | null;
  /** Legal identity lines (company, tax ID, address). `null` hides the row. */
  legal?: string[] | null;
  /** Static text; the block does not compute the year. */
  copyright?: string;
  /** Accessible name of the <nav>. */
  navLabel?: string;
  /** Link element for group links, e.g. next/link. Receives href, className and children. */
  linkComponent?: React.ElementType<{
    href: string;
    className?: string;
    children?: React.ReactNode;
  }>;
  /** "ignore" keeps the mouse hot spot for visitors who prefer reduced motion. */
  reducedMotion?: "respect" | "ignore";
  className?: string;
  /** Merged onto the rows wrapper (tagline, navigation, contact, legal), e.g. `mx-auto max-w-6xl md:px-6` to line it up with the page container. The wordmark stays full width. */
  contentClassName?: string;
}

const SAMPLE_GROUPS: FooterForgeGroup[] = [
  {
    links: [
      { label: "Services", href: "/services" },
      { label: "Projects", href: "/projects" },
      { label: "Blog", href: "/blog" },
      { label: "About", href: "/about" },
      { label: "Contact", href: "/contact" },
    ],
  },
];

const SAMPLE_CONTACT: FooterForgeLink[] = [
  { label: "hello@forge.studio", href: "mailto:hello@forge.studio" },
  { label: "+84 900 000 000", href: "tel:+84900000000" },
];

const SAMPLE_LEGAL = ["Forge Studio Co., Ltd.", "Tax ID 0100000000", "1 Example Street, Hanoi"];

// The prefix keeps these clear of a consumer's own custom properties, since @property is global.
// Registering them as typed values is what lets the hot spot glide and cool down instead of jumping.
const HEAT_CSS = `@property --leo-heat-x { syntax: "<percentage>"; inherits: true; initial-value: 50%; }
@property --leo-heat-y { syntax: "<percentage>"; inherits: true; initial-value: 50%; }
@property --leo-heat { syntax: "<number>"; inherits: true; initial-value: 0; }
.leo-footer-forge-wordmark { transition: --leo-heat-x 300ms ease-out, --leo-heat-y 300ms ease-out, --leo-heat 1500ms ease-out; }
.leo-footer-forge-wordmark[data-hot] { --leo-heat: 1; transition: --leo-heat-x 300ms ease-out, --leo-heat-y 300ms ease-out, --leo-heat 150ms ease-out; }`;

const STEEL = "linear-gradient(to bottom, var(--foreground) 25%, var(--muted-foreground))";
const BASE_HEAT = "linear-gradient(to top, var(--primary), transparent 40%)";
const HOT_SPOT =
  "radial-gradient(circle 0.7em at var(--leo-heat-x) var(--leo-heat-y), color-mix(in oklab, var(--foreground) 70%, var(--primary)), var(--primary) 45%, transparent)";

/** Font size that makes `text` span close to the full width of its `container-type: inline-size` parent. */
export function wordmarkSize(text: string): string {
  const k = Math.round(Math.max(text.length, 4) * 0.5 * 100) / 100;
  return `calc(100cqi / ${k})`;
}

const linkBase =
  "rounded-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background";
const navLink = cn(linkBase, "text-foreground/80 hover:text-foreground");

const layerClass = "pointer-events-none absolute inset-0 select-none bg-clip-text text-transparent";
const textClass =
  "font-[family-name:var(--font-heading)] leading-[0.8] whitespace-nowrap font-semibold tracking-tight";

function Wordmark({ text, animate }: { text: string; animate: boolean }) {
  const ref = useRef<HTMLDivElement>(null);
  const frame = useRef<number | null>(null);
  const point = useRef({ x: 50, y: 50 });

  useEffect(
    () => () => {
      if (frame.current !== null) cancelAnimationFrame(frame.current);
    },
    [],
  );

  const onMove = (e: React.PointerEvent<HTMLDivElement>) => {
    // Touch has no hover, so heat stuck under a finger would only mislead.
    if (e.pointerType !== "mouse") return;
    const el = ref.current;
    if (!el) return;
    const rect = el.getBoundingClientRect();
    if (rect.width === 0 || rect.height === 0) return;
    point.current = {
      x: ((e.clientX - rect.left) / rect.width) * 100,
      y: ((e.clientY - rect.top) / rect.height) * 100,
    };
    if (frame.current !== null) return;
    frame.current = requestAnimationFrame(() => {
      frame.current = null;
      el.style.setProperty("--leo-heat-x", `${+point.current.x.toFixed(1)}%`);
      el.style.setProperty("--leo-heat-y", `${+point.current.y.toFixed(1)}%`);
      el.setAttribute("data-hot", "");
    });
  };

  const onLeave = () => {
    // A frame queued before the pointer left must not re-heat the letters afterwards.
    if (frame.current !== null) {
      cancelAnimationFrame(frame.current);
      frame.current = null;
    }
    ref.current?.removeAttribute("data-hot");
  };

  // Reduced motion can flip on mid-hover; the layer is gone by then, so a stale hot flag would
  // resurface when motion returns.
  useEffect(() => {
    if (!animate) ref.current?.removeAttribute("data-hot");
  }, [animate]);

  const style = { fontSize: wordmarkSize(text) };

  return (
    <div
      ref={ref}
      data-wordmark=""
      onPointerMove={animate ? onMove : undefined}
      onPointerLeave={animate ? onLeave : undefined}
      className="leo-footer-forge-wordmark relative translate-y-[10%] [container-type:inline-size]"
    >
      {/* Hoisted by React 19 and de-duplicated across instances. */}
      <style href="leo-footer-forge" precedence="default">
        {HEAT_CSS}
      </style>
      <p
        className={cn(textClass, "bg-clip-text text-transparent")}
        style={{ ...style, backgroundImage: STEEL }}
      >
        {text}
      </p>
      <p
        aria-hidden="true"
        className={cn(textClass, layerClass)}
        style={{ ...style, backgroundImage: BASE_HEAT }}
      >
        {text}
      </p>
      {animate && (
        <p
          aria-hidden="true"
          data-heat=""
          className={cn(textClass, layerClass)}
          style={{ ...style, backgroundImage: HOT_SPOT, opacity: "var(--leo-heat)" }}
        >
          {text}
        </p>
      )}
    </div>
  );
}

function ContactLink({ link }: { link: FooterForgeLink }) {
  const external = /^https?:\/\//i.test(link.href);
  return (
    <a
      href={link.href}
      className={navLink}
      {...(external ? { target: "_blank", rel: "noopener noreferrer" } : {})}
    >
      {link.label}
    </a>
  );
}

export default function FooterForge({
  wordmark = "Forge Studio",
  tagline = "Custom websites, built to be handed over.",
  groups = SAMPLE_GROUPS,
  contact = SAMPLE_CONTACT,
  legal = SAMPLE_LEGAL,
  copyright = "© Forge Studio. All rights reserved.",
  navLabel = "Footer",
  linkComponent: Link = "a",
  reducedMotion = "respect",
  className,
  contentClassName,
}: FooterForgeProps) {
  const { animate } = useForgeMotion(reducedMotion);
  const hasContact = contact !== null && contact.length > 0;
  const hasLegal = legal !== null && legal.length > 0;

  return (
    <footer
      className={cn("relative isolate overflow-hidden bg-background text-foreground", className)}
    >
      <div className={cn("px-6 pt-16 md:px-12 md:pt-24", contentClassName)}>
        <div className="grid gap-12 md:grid-cols-2">
          <p className="max-w-sm text-lg text-foreground">{tagline}</p>
          <div className="grid gap-10 sm:grid-cols-2">
            <nav aria-label={navLabel} className="grid gap-8 sm:grid-cols-2">
              {groups.map((group, i) => (
                // biome-ignore lint/suspicious/noArrayIndexKey: groups have no id and titles may repeat
                <div key={i}>
                  {group.title && (
                    <h2 className="font-mono text-xs tracking-widest text-muted-foreground uppercase">
                      {group.title}
                    </h2>
                  )}
                  <ul className={cn("grid gap-3 text-sm", group.title && "mt-4")}>
                    {group.links.map((link) => (
                      <li key={`${link.href}|${link.label}`}>
                        <Link href={link.href} className={navLink}>
                          {link.label}
                        </Link>
                      </li>
                    ))}
                  </ul>
                </div>
              ))}
            </nav>
            {hasContact && (
              <ul className="grid content-start gap-3 text-sm">
                {contact.map((link) => (
                  <li key={`${link.href}|${link.label}`}>
                    <ContactLink link={link} />
                  </li>
                ))}
              </ul>
            )}
          </div>
        </div>
        <div className="mt-16 border-t border-border py-6">
          {hasLegal && (
            <ul
              data-legal=""
              className="flex flex-col gap-1 font-mono text-xs text-muted-foreground md:flex-row md:flex-wrap md:gap-x-0"
            >
              {legal.map((line, i) => (
                // biome-ignore lint/suspicious/noArrayIndexKey: lines are plain strings and may repeat
                <li key={i}>
                  {line}
                  {i < legal.length - 1 && (
                    <span aria-hidden="true" className="mx-3 hidden md:inline">
                      ·
                    </span>
                  )}
                </li>
              ))}
            </ul>
          )}
          <p className={cn("font-mono text-xs text-muted-foreground", hasLegal && "mt-3")}>
            {copyright}
          </p>
        </div>
      </div>
      {wordmark && (
        <div className="px-6 md:px-12">
          <Wordmark text={wordmark} animate={animate} />
        </div>
      )}
    </footer>
  );
}