A footer with a newsletter and a wordmark that leans toward you

Build a landing page footer in React: a newsletter form with a real success state, link columns, live studio clocks and a full-width wordmark whose letters rise toward the pointer.

6 min read

The real component. Click the picture to open it live and try it before you read how it was built.

The footer is the last thing people see. This one ends the page on the brand's name across the full width, and the letters rise toward the pointer as it passes.

Letters that feel the pointer

Each letter measures how far its centre is from the pointer, in letter widths, and rises within a short reach. When the pointer leaves, it is treated as far away to the left so nothing stays lifted.

src/registry/footers/newsletter-wordmark/pointer-wordmark.tsx

"use client";

import { useRef, type PointerEvent } from "react";
import { motion, useMotionValue, useSpring, useTransform, type MotionValue } from "motion/react";
import { usePrefersReducedMotion } from "@/hooks/use-prefers-reduced-motion";
import { cn } from "@/lib/utils";

// Where the pointer "is" while it's away: far enough left that no letter feels it.
const POINTER_AWAY = -10_000;
// How far the pointer's pull reaches, in letter widths from a letter's centre.
const REACH_IN_LETTERS = 1.4;
// The most a letter rises, as a share of its own height: enough to climb out of the crop.
const MAX_LIFT_PERCENT = 22;
const RESTING_OPACITY = 0.1;
const LIFTED_OPACITY = 0.32;
const LIFT_SPRING = { stiffness: 220, damping: 26, mass: 0.6 };

interface PointerWordmarkProps {
  text: string;
  className?: string;
}

// The brand's name spread across the footer's width. Letters near the pointer rise out of the crop and
// darken a little, the pull fading with distance. Only transforms and opacity move; still for reduced motion.
export function PointerWordmark({ text, className }: PointerWordmarkProps) {
  const shouldReduceMotion = usePrefersReducedMotion();
  const pointerX = useMotionValue(POINTER_AWAY);

  const trackPointer = (event: PointerEvent<HTMLDivElement>) => {
    if (shouldReduceMotion) return;
    pointerX.set(event.clientX - event.currentTarget.getBoundingClientRect().left);
  };

  return (
    <div
      aria-hidden
      onPointerMove={trackPointer}
      onPointerLeave={() => pointerX.set(POINTER_AWAY)}
      className={cn(
        "relative flex justify-between leading-none font-semibold tracking-tighter text-foreground select-none",
        className,
      )}
    >
      {Array.from(text).map((letter, index) => (
        <WordmarkLetter key={`${letter}-${index}`} letter={letter} pointerX={pointerX} />
      ))}
    </div>
  );
}

function WordmarkLetter({ letter, pointerX }: { letter: string; pointerX: MotionValue<number> }) {
  const ref = useRef<HTMLSpanElement>(null);
  // offsetLeft ignores transforms, so a rising letter never moves its own target.
  const pull = useTransform(pointerX, (x) => {
    const element = ref.current;
    if (!element) return 0;
    const centre = element.offsetLeft + element.offsetWidth / 2;
    return Math.max(0, 1 - Math.abs(x - centre) / (element.offsetWidth * REACH_IN_LETTERS));
  });
  const easedPull = useSpring(pull, LIFT_SPRING);
  const y = useTransform(easedPull, (amount) => `${-amount * MAX_LIFT_PERCENT}%`);
  const opacity = useTransform(easedPull, [0, 1], [RESTING_OPACITY, LIFTED_OPACITY]);

  return (
    <motion.span ref={ref} style={{ y, opacity }} className="inline-block will-change-transform">
      {letter}
    </motion.span>
  );
}
The wordmark

A newsletter that confirms properly

The email check is strict enough to catch typos and loose enough for every real address. On success, a thank-you takes the form's place and receives focus so screen readers announce it, with a way back to use another address.

src/registry/footers/newsletter-wordmark/newsletter-form.tsx

"use client";

import { useId, useState, type FormEvent } from "react";
import { Button } from "@/components/ui/button";
import { cn } from "@/lib/utils";
import { NewsletterSuccess } from "./newsletter-success";

// Something, an @, something, a dot and at least two letters: strict enough to catch typos, loose enough
// for every real address.
const EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/;

export interface NewsletterCopy {
  title: string;
  description: string;
  inputLabel: string;
  placeholder: string;
  buttonLabel: string;
  // The quiet line under the field before anything goes wrong.
  hint: string;
  emptyError: string;
  invalidError: string;
  successTitle: string;
  // "{email}" is replaced by the address they typed.
  successMessage: string;
  resetLabel: string;
}

function getEmailProblem(email: string, copy: NewsletterCopy): string | null {
  if (!email) return copy.emptyError;
  return EMAIL_PATTERN.test(email) ? null : copy.invalidError;
}

// A newsletter sign-up that checks the address as you send it and answers inline. It sends nothing: post
// the address to your list provider where `submit` accepts it.
export function NewsletterForm({ copy }: { copy: NewsletterCopy }) {
  const id = useId();
  const [email, setEmail] = useState("");
  const [error, setError] = useState<string | null>(null);
  const [subscribedEmail, setSubscribedEmail] = useState<string | null>(null);

  const submit = (event: FormEvent<HTMLFormElement>) => {
    event.preventDefault();
    const address = email.trim();
    const problem = getEmailProblem(address, copy);
    setError(problem);
    if (problem) return;
    setSubscribedEmail(address);
  };

  const reset = () => {
    setSubscribedEmail(null);
    setEmail("");
  };

  return (
    <div>
      <p className="font-medium text-foreground">{copy.title}</p>
      <p className="mt-1 text-sm text-muted-foreground">{copy.description}</p>
      {subscribedEmail ? (
        <NewsletterSuccess
          title={copy.successTitle}
          message={copy.successMessage}
          email={subscribedEmail}
          resetLabel={copy.resetLabel}
          onReset={reset}
        />
      ) : (
        <form noValidate onSubmit={submit} className="mt-4">
          <label htmlFor={`${id}-email`} className="sr-only">
            {copy.inputLabel}
          </label>
          <div
            className={cn(
              "flex h-12 items-center gap-2 rounded-full border bg-card p-1 pl-4 transition-colors focus-within:ring-3 focus-within:ring-ring/50",
              error && "border-primary",
            )}
          >
            <input
              id={`${id}-email`}
              type="email"
              autoComplete="email"
              inputMode="email"
              placeholder={copy.placeholder}
              value={email}
              onChange={(event) => {
                setEmail(event.target.value);
                setError(null);
              }}
              aria-invalid={error !== null}
              aria-describedby={`${id}-message`}
              className="h-full min-w-0 flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground"
            />
            <Button type="submit" variant="ink" className="h-10 px-4">
              {copy.buttonLabel}
            </Button>
          </div>
          <p
            id={`${id}-message`}
            aria-live="polite"
            className={cn("mt-2 pl-4 text-xs", error ? "text-primary" : "text-muted-foreground")}
          >
            {error ?? copy.hint}
          </p>
        </form>
      )}
    </div>
  );
}
The form

Studio clocks

The studios' local times are read after the page loads and refreshed often enough that the minute turns over on time.

More articles