# Aurora Hero
*URL: https://www.grettech.com/components/aurora-hero*

A launch-page hero with silk aurora ribbons drawn on canvas under film grain, a cursor-lit dot grid, rotating words, an email sign-up and a logo marquee.

- Canvas aurora ribbons that glow in dark mode, under film grain
- Headline eases in word by word and ends in rotating words
- Email sign-up with loading, success and error states
- 30fps cap, paused off-screen; still for reduced motion

## Install with the shadcn CLI
```bash
npx shadcn@latest add https://www.grettech.com/api/registry/aurora-hero
```
With its demo: `npx shadcn@latest add https://www.grettech.com/api/registry/aurora-hero-demo`

**Dependencies:** npm: motion, clsx, tailwind-merge

## Manual installation
**Step 1: Install dependencies**
Install the packages this component uses and the shadcn/ui components it builds on. It also needs the `cn` helper in `lib/utils.ts`, which `npx shadcn@latest init` adds.

```bash
npm install motion clsx tailwind-merge
```

**Step 2: Copy the source code**
Add these files to your project components directory.

File: `components/ui/aurora-hero.tsx`
```tsx
"use client"

import { cn } from "@/lib/utils"
import {
  animate,
  motion,
  MotionConfig,
  useAnimate,
  useReducedMotion,
  type AnimationPlaybackControls,
} from "motion/react"
import * as React from "react"

export type AuroraAnnouncement = {
  /** Short tag in the pill, e.g. "New" */
  tag?: string
  label: string
  href?: string
}

export type AuroraSignup = {
  placeholder?: string
  buttonLabel?: string
  /** Posts the form natively, e.g. to a newsletter service */
  action?: string
  /** Called with the email; a returned promise shows a loading state */
  onSubmit?: (email: string) => void | Promise<void>
  successMessage?: string
  /** Small print under the form */
  note?: string
}

export type AuroraLogo = {
  name: string
  /** Logo image; the name is shown as a wordmark without one */
  src?: string
}

export interface AuroraHeroProps extends Omit<
  React.HTMLAttributes<HTMLElement>,
  "title"
> {
  announcement?: AuroraAnnouncement
  title: string
  /** Words that take turns at the end of the title */
  rotatingWords?: string[]
  description?: string
  signup?: AuroraSignup
  /** Extra actions under the sign-up form */
  children?: React.ReactNode
  logos?: AuroraLogo[]
  logosLabel?: string
  /** Colours of the aurora ribbons (any CSS colours) */
  colors?: string[]
  /** Light up the dot grid around the cursor */
  spotlight?: boolean
  /** Ribbon speed; 0 holds them still */
  speed?: number
}

const DEFAULT_COLORS = ["#22d3ee", "#6366f1", "#a855f7", "#ec4899", "#34d399"]

// Film grain as an inline SVG, laid over the ribbons
const GRAIN = `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`

const WORDMARKS = [
  "text-lg font-semibold tracking-tight",
  "text-lg font-bold italic",
  "text-sm font-medium tracking-[0.2em] uppercase",
  "font-serif text-xl",
]

/** Rise into place, after `delay` seconds (opacity only for reduced motion) */
const rise = (delay: number) => ({
  initial: { opacity: 0, y: "0.35em" },
  animate: { opacity: 1, y: "0em" },
  transition: { duration: 0.7, ease: [0.2, 0.7, 0.2, 1] as const, delay },
})

const REDUCED = "(prefers-reduced-motion: reduce)"
function subscribeReducedMotion(onChange: () => void) {
  const media = window.matchMedia(REDUCED)
  media.addEventListener("change", onChange)
  return () => media.removeEventListener("change", onChange)
}

/** Dark mode as next-themes and shadcn set it (class or color-scheme) */
function isDark() {
  const root = document.documentElement
  return (
    root.classList.contains("dark") ||
    getComputedStyle(root).colorScheme === "dark"
  )
}

/**
 * Silk ribbons on a canvas drawn at a fifth of the size: the browser's
 * upscaling softens them for free. Capped at 30fps, paused off-screen and
 * in background tabs, and drawn once (still) for reduced motion.
 */
function AuroraCanvas({ colors, speed }: { colors: string[]; speed: number }) {
  const wrap = React.useRef<HTMLDivElement>(null)
  const canvas = React.useRef<HTMLCanvasElement>(null)
  const palette = colors.join("|")

  React.useEffect(() => {
    const el = canvas.current
    const box = wrap.current
    const ctx = el?.getContext("2d")
    if (!el || !box || !ctx) return
    const hues = palette.split("|")
    const SCALE = 0.35
    let w = 0
    let h = 0
    let frame = 0
    let visible = true
    let last = 0
    const still = window.matchMedia(REDUCED).matches || speed === 0

    const draw = (time: number) => {
      const t = (time / 1000) * speed
      const dark = isDark()
      ctx.setTransform(SCALE, 0, 0, SCALE, 0, 0)
      ctx.clearRect(0, 0, w, h)
      ctx.globalCompositeOperation = dark ? "lighter" : "source-over"
      ctx.filter = "blur(1.5px)"
      const n = Math.max(3, Math.min(7, hues.length + 1))
      const steps = 40
      const xAt = (s: number) => -w * 0.1 + (w * 1.2 * s) / steps
      for (let i = 0; i < n; i++) {
        const base = h * (0.1 + i * 0.08)
        const amp = h * (0.07 + 0.025 * (i % 3))
        const k1 = ((1.6 + i * 0.3) * Math.PI) / w
        const k2 = ((3.1 - i * 0.2) * Math.PI) / w
        const top: number[] = []
        for (let s = 0; s <= steps; s++) {
          const x = xAt(s)
          top.push(
            base +
              amp * Math.sin(x * k1 + t * (0.32 + i * 0.05) + i * 1.3) +
              amp * 0.45 * Math.sin(x * k2 - t * 0.21 + i * 2.1)
          )
        }
        // A curtain: bright along the crest, fading downwards
        const hue = hues[i % hues.length]
        const grad = ctx.createLinearGradient(
          0,
          base - amp,
          0,
          base + amp + h * 0.22
        )
        grad.addColorStop(0, "transparent")
        grad.addColorStop(0.3, hue)
        grad.addColorStop(1, "transparent")
        ctx.fillStyle = grad
        ctx.globalAlpha = dark ? 0.5 : 0.34
        ctx.beginPath()
        for (let s = 0; s <= steps; s++) ctx.lineTo(xAt(s), top[s])
        for (let s = steps; s >= 0; s--) {
          const x = xAt(s)
          const thick =
            h * (0.1 + 0.06 * Math.sin(x * k2 * 0.7 + t * 0.4 + i * 0.9))
          ctx.lineTo(x, top[s] + thick)
        }
        ctx.closePath()
        ctx.fill()
        // A thin highlight along the crest gives the silk its sheen
        ctx.globalAlpha = dark ? 0.35 : 0.5
        ctx.strokeStyle = dark ? "rgba(255,255,255,0.6)" : hue
        ctx.lineWidth = 1.5
        ctx.beginPath()
        for (let s = 0; s <= steps; s++) ctx.lineTo(xAt(s), top[s])
        ctx.stroke()
      }
      ctx.globalAlpha = 1
      ctx.filter = "none"
      ctx.globalCompositeOperation = "source-over"
    }

    const resize = () => {
      const rect = box.getBoundingClientRect()
      w = rect.width
      h = rect.height
      el.width = Math.max(1, Math.round(w * SCALE))
      el.height = Math.max(1, Math.round(h * SCALE))
      draw(last)
    }
    const loop = (time: number) => {
      frame = requestAnimationFrame(loop)
      if (!visible || document.hidden || time - last < 1000 / 30) return
      last = time
      draw(time)
    }

    const sizer = new ResizeObserver(resize)
    sizer.observe(box)
    const seen = new IntersectionObserver(([entry]) => {
      visible = entry?.isIntersecting ?? true
    })
    seen.observe(box)
    // Redraw when the theme changes, so a still aurora follows it too
    const theme = new MutationObserver(() => draw(last))
    theme.observe(document.documentElement, {
      attributes: true,
      attributeFilter: ["class", "style"],
    })
    resize()
    if (!still) frame = requestAnimationFrame(loop)
    return () => {
      cancelAnimationFrame(frame)
      sizer.disconnect()
      seen.disconnect()
      theme.disconnect()
    }
  }, [palette, speed])

  return (
    <div ref={wrap} aria-hidden="true" className="absolute inset-0">
      <canvas ref={canvas} className="absolute inset-0 size-full" />
    </div>
  )
}

function RotatingWords({
  words,
  colors,
}: {
  words: string[]
  colors: string[]
}) {
  const [index, setIndex] = React.useState(0)
  const reduced = React.useSyncExternalStore(
    subscribeReducedMotion,
    () => window.matchMedia(REDUCED).matches,
    () => false
  )
  React.useEffect(() => {
    if (words.length < 2 || reduced) return
    const timer = window.setInterval(
      () => setIndex((i) => (i + 1) % words.length),
      2600
    )
    return () => window.clearInterval(timer)
  }, [words.length, reduced])

  const previous = (index - 1 + words.length) % words.length
  return (
    // Every word sits in the same grid cell, so the line never reflows
    <span className="inline-grid justify-items-start">
      {words.map((word, i) => (
        <motion.span
          key={`${word}-${i}`}
          aria-hidden={i !== index}
          className="col-start-1 row-start-1 bg-clip-text pb-[0.08em] text-transparent"
          style={{
            backgroundImage: `linear-gradient(95deg, ${colors[1] ?? colors[0]}, ${colors[3] ?? colors[2] ?? colors[0]})`,
          }}
          initial={false}
          animate={
            // The new word rises in as the old one lifts away
            i === index
              ? { opacity: 1, y: "0em", filter: "blur(0px)" }
              : i === previous
                ? { opacity: 0, y: "-0.3em", filter: "blur(6px)" }
                : { opacity: 0, y: "0.3em", filter: "blur(6px)" }
          }
          transition={{ duration: 0.5, ease: "easeOut" }}
        >
          {word}
        </motion.span>
      ))}
    </span>
  )
}

function Announcement({ tag, label, href }: AuroraAnnouncement) {
  const className = cn(
    "mb-7 inline-flex items-center gap-2 rounded-full bg-background/70 py-1 pr-3 text-xs font-medium text-foreground shadow-sm ring-1 shadow-black/5 ring-black/10 backdrop-blur-md transition-colors sm:text-sm dark:ring-white/15",
    tag ? "pl-1" : "pl-3",
    href && "hover:bg-background"
  )
  const inner = (
    <>
      {tag && (
        <span className="rounded-full bg-foreground px-2 py-0.5 text-[11px] font-semibold text-background">
          {tag}
        </span>
      )}
      <span>{label}</span>
      {href && (
        <svg
          viewBox="0 0 16 16"
          aria-hidden="true"
          className="size-3.5 text-muted-foreground"
          fill="none"
          stroke="currentColor"
          strokeWidth="1.5"
        >
          <path d="M6 3l5 5-5 5" strokeLinecap="round" strokeLinejoin="round" />
        </svg>
      )}
    </>
  )
  return href ? (
    <motion.a href={href} className={className} {...rise(0)}>
      {inner}
    </motion.a>
  ) : (
    <motion.p className={className} {...rise(0)}>
      {inner}
    </motion.p>
  )
}

function Signup({ signup, delay }: { signup: AuroraSignup; delay: number }) {
  const [state, setState] = React.useState<
    "idle" | "loading" | "done" | "error"
  >("idle")
  const id = React.useId()

  const onSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
    // With only an action, let the browser post the form
    if (signup.action && !signup.onSubmit) return
    e.preventDefault()
    const email = String(new FormData(e.currentTarget).get("email") ?? "")
    try {
      setState("loading")
      await signup.onSubmit?.(email)
      setState("done")
    } catch {
      setState("error")
    }
  }

  return (
    <motion.div className="mt-9 w-full max-w-md" {...rise(delay)}>
      {state === "done" ? (
        <p
          role="status"
          className="flex items-center justify-center gap-2 rounded-full bg-background/80 px-4 py-3 text-sm text-foreground ring-1 ring-black/10 backdrop-blur-md dark:ring-white/15"
        >
          <svg
            viewBox="0 0 16 16"
            aria-hidden="true"
            className="size-4 text-emerald-500"
            fill="none"
            stroke="currentColor"
            strokeWidth="2"
          >
            <path
              d="M3 8.5l3 3 7-7"
              strokeLinecap="round"
              strokeLinejoin="round"
            />
          </svg>
          {signup.successMessage ?? "Thanks, you're on the list."}
        </p>
      ) : (
        <form
          action={signup.action}
          method={signup.action ? "post" : undefined}
          onSubmit={onSubmit}
          className="flex items-center gap-2 rounded-full bg-background/80 p-1.5 pl-5 shadow-[0_10px_40px_-12px_rgba(0,0,0,0.25)] ring-1 ring-black/10 backdrop-blur-md transition-shadow focus-within:ring-2 focus-within:ring-ring dark:ring-white/15"
        >
          <label htmlFor={id} className="sr-only">
            Email address
          </label>
          <input
            id={id}
            name="email"
            type="email"
            required
            autoComplete="email"
            placeholder={signup.placeholder ?? "you@company.com"}
            className="min-w-0 flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground"
          />
          <button
            type="submit"
            disabled={state === "loading"}
            className="shrink-0 rounded-full bg-foreground px-5 py-2.5 text-sm font-medium text-background shadow-sm transition-all hover:opacity-90 active:scale-[0.98] disabled:opacity-60"
          >
            {state === "loading" ? "Sending…" : (signup.buttonLabel ?? "Join")}
          </button>
        </form>
      )}
      {state === "error" && (
        <p role="alert" className="mt-2 text-center text-xs text-destructive">
          That didn&apos;t work. Please try again.
        </p>
      )}
      {signup.note && state !== "done" && (
        <p className="mt-3 text-center text-xs text-muted-foreground">
          {signup.note}
        </p>
      )}
    </motion.div>
  )
}

function LogoMarquee({
  logos,
  label,
}: {
  logos: AuroraLogo[]
  label?: string
}) {
  // Two copies scroll by forever; -50% lands exactly on the second. It
  // eases to a stop on hover, and holds still for reduced motion
  const [scope] = useAnimate<HTMLDivElement>()
  const still = useReducedMotion() ?? false
  const [hovered, setHovered] = React.useState(false)
  const run = React.useRef<AnimationPlaybackControls | null>(null)
  const seconds = Math.max(20, logos.length * 5)
  React.useEffect(() => {
    if (still || !scope.current) return
    run.current = animate(
      scope.current,
      { x: ["0%", "-50%"] },
      { duration: seconds, ease: "linear", repeat: Infinity }
    )
    return () => run.current?.stop()
  }, [scope, seconds, still])
  React.useEffect(() => {
    const scroll = run.current
    if (!scroll) return
    const ease = animate(scroll.speed, hovered ? 0 : 1, {
      duration: 0.6,
      ease: "easeOut",
      onUpdate: (v) => (scroll.speed = v),
    })
    return () => ease.stop()
  }, [hovered])

  const row = (copy: boolean) => (
    <ul
      aria-hidden={copy || undefined}
      className="flex shrink-0 items-center gap-14 pr-14"
    >
      {logos.map((logo, i) => (
        <li key={`${logo.name}-${i}`} className="shrink-0">
          {logo.src ? (
            // eslint-disable-next-line @next/next/no-img-element
            <img
              src={logo.src}
              alt={copy ? "" : logo.name}
              className="h-6 w-auto opacity-70 grayscale"
            />
          ) : (
            <span
              className={cn(
                "whitespace-nowrap text-foreground/45",
                WORDMARKS[i % WORDMARKS.length]
              )}
            >
              {logo.name}
            </span>
          )}
        </li>
      ))}
    </ul>
  )
  return (
    <div className="relative mt-16 w-full max-w-4xl sm:mt-24">
      {label && (
        <p className="mb-6 text-center text-xs font-medium tracking-wide text-muted-foreground uppercase">
          {label}
        </p>
      )}
      <div
        className="overflow-hidden [mask-image:linear-gradient(to_right,transparent,black_15%,black_85%,transparent)]"
        onPointerEnter={() => setHovered(true)}
        onPointerLeave={() => setHovered(false)}
      >
        <div ref={scope} className="flex w-max">
          {row(false)}
          {row(true)}
        </div>
      </div>
    </div>
  )
}

/**
 * A launch-page hero: silk ribbons of colour drifting across the top under
 * a fine film grain, a dot grid that lights up around the cursor, a
 * headline that eases in word by word and ends in rotating words, an email
 * sign-up and a scrolling row of logos. The ribbons glow in dark mode.
 */
export const AuroraHero = React.forwardRef<HTMLElement, AuroraHeroProps>(
  (
    {
      announcement,
      title,
      rotatingWords = [],
      description,
      signup,
      children,
      logos = [],
      logosLabel,
      colors = DEFAULT_COLORS,
      spotlight = true,
      speed = 1,
      className,
      onPointerMove,
      ...props
    },
    ref
  ) => {
    const palette = colors.length ? colors : DEFAULT_COLORS
    const words = title.split(/\s+/).filter(Boolean)
    const textDelay = 0.1 + (words.length + 1) * 0.06

    return (
      <section
        ref={ref}
        onPointerMove={(e) => {
          if (spotlight) {
            const box = e.currentTarget.getBoundingClientRect()
            e.currentTarget.style.setProperty(
              "--aurora-x",
              `${e.clientX - box.left}px`
            )
            e.currentTarget.style.setProperty(
              "--aurora-y",
              `${e.clientY - box.top}px`
            )
          }
          onPointerMove?.(e)
        }}
        className={cn(
          "group/aurora relative isolate flex w-full flex-col items-center overflow-hidden bg-background px-6 pt-24 pb-16 sm:pt-32",
          className
        )}
        {...props}
      >
        {/* Ribbons, grain, and a fade into the page */}
        <div
          aria-hidden="true"
          className="pointer-events-none absolute inset-0 -z-20"
        >
          <AuroraCanvas colors={palette} speed={speed} />
          <div
            className="absolute inset-0 opacity-[0.22] mix-blend-overlay dark:opacity-[0.14]"
            style={{ backgroundImage: GRAIN }}
          />
          <div className="absolute inset-x-0 bottom-0 h-3/5 bg-linear-to-b from-transparent to-background" />
        </div>

        {/* Dot grid, brighter around the cursor */}
        <div
          aria-hidden="true"
          className="pointer-events-none absolute inset-0 -z-10 [background-image:radial-gradient(color-mix(in_oklab,currentColor_12%,transparent)_1px,transparent_1px)] [mask-image:radial-gradient(ellipse_70%_60%_at_50%_30%,black,transparent)] [background-size:22px_22px] text-foreground"
        />
        {spotlight && (
          <div
            aria-hidden="true"
            className="pointer-events-none absolute inset-0 -z-10 [background-image:radial-gradient(color-mix(in_oklab,currentColor_60%,transparent)_1.25px,transparent_1.25px)] [background-size:22px_22px] text-foreground opacity-0 transition-opacity duration-300 group-hover/aurora:opacity-100"
            style={{
              maskImage:
                "radial-gradient(200px circle at var(--aurora-x, 50%) var(--aurora-y, 50%), black, transparent)",
              WebkitMaskImage:
                "radial-gradient(200px circle at var(--aurora-x, 50%) var(--aurora-y, 50%), black, transparent)",
            }}
          />
        )}

        {/* Reduced motion keeps the fades but drops the movement */}
        <MotionConfig reducedMotion="user">
          <div className="flex max-w-3xl flex-col items-center text-center">
            {announcement && <Announcement {...announcement} />}

            <h1 className="text-4xl leading-[1.05] font-semibold tracking-[-0.03em] text-balance text-foreground sm:text-6xl md:text-7xl">
              {words.map((word, i) => (
                <React.Fragment key={`${word}-${i}`}>
                  <motion.span
                    className="inline-block"
                    {...rise(0.1 + i * 0.06)}
                  >
                    {word}
                  </motion.span>{" "}
                </React.Fragment>
              ))}
              {rotatingWords.length > 0 && (
                <motion.span
                  className="inline-block"
                  {...rise(0.1 + words.length * 0.06)}
                >
                  <RotatingWords words={rotatingWords} colors={palette} />
                </motion.span>
              )}
            </h1>

            {description && (
              <motion.p
                className="mt-6 max-w-xl text-base text-pretty text-muted-foreground sm:text-lg"
                {...rise(textDelay)}
              >
                {description}
              </motion.p>
            )}

            {signup && <Signup signup={signup} delay={textDelay + 0.1} />}

            {children && (
              <motion.div
                className="mt-6 flex flex-wrap items-center justify-center gap-3"
                {...rise(textDelay + 0.2)}
              >
                {children}
              </motion.div>
            )}
          </div>

          {logos.length > 0 && <LogoMarquee logos={logos} label={logosLabel} />}
        </MotionConfig>
      </section>
    )
  }
)
AuroraHero.displayName = "AuroraHero"

```

**Step 3: Framework Adjustments (Optional)**
If you are manually copying this code into a Vite or Remix project (without using the CLI), make sure to remove the `"use client";` directive from the very top of the file.

## Props
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
| `title` | `string` | - | Yes | The main headline, before the rotating words. |
| `rotatingWords` | `string[]` | `[]` | No | Words that take turns at the end of the title. |
| `announcement` | `AuroraAnnouncement` | - | No | Pill above the title, e.g. for a launch. |
| `announcement.label` | `string` | - | Yes | Pill text. |
| `announcement.tag` | `string` | - | No | Short tag, e.g. "New". |
| `announcement.href` | `string` | - | No | Makes the pill a link. |
| `description` | `string` | - | No | Supporting text under the title. |
| `signup` | `AuroraSignup` | - | No | Email sign-up form under the description. |
| `signup.onSubmit` | `(email: string) => void \| Promise<void>` | - | No | Called with the email. A returned promise shows a loading state; throwing shows an error. |
| `signup.action` | `string` | - | No | Posts the form natively instead, e.g. to a newsletter service. |
| `signup.placeholder` | `string` | `"you@company.com"` | No | Input placeholder. |
| `signup.buttonLabel` | `string` | `"Join"` | No | Button text. |
| `signup.successMessage` | `string` | - | No | Shown after a successful submit. |
| `signup.note` | `string` | - | No | Small print under the form. |
| `children` | `React.ReactNode` | - | No | Extra actions under the sign-up form. |
| `logos` | `AuroraLogo[]` | `[]` | No | Logos in the scrolling strip. Names without an image are shown as wordmarks. |
| `logos.name` | `string` | - | Yes | Company name, also the image's alt text. |
| `logos.src` | `string` | - | No | Logo image URL. |
| `logosLabel` | `string` | - | No | Line above the logo strip. |
| `colors` | `string[]` | `["#22d3ee", "#6366f1", "#a855f7", "#ec4899", "#34d399"]` | No | Three or four colours for the aurora and the rotating words. |
| `spotlight` | `boolean` | `true` | No | Light up the dot grid around the cursor. |
| `speed` | `number` | `1` | No | Ribbon speed; 0 holds them still. |
| `className` | `string` | - | No | Extra classes for the section. |

## Usage
```tsx
"use client"

import { AuroraHero } from "@/components/ui/aurora-hero"

export default function AuroraHeroDemo() {
  return (
    <AuroraHero
      announcement={{
        tag: "New",
        label: "Lumen 2.0: offline mode and shared spaces",
        href: "#changelog",
      }}
      title="A calmer workspace for"
      rotatingWords={["product teams", "agencies", "founders", "writers"]}
      description="Lumen keeps docs, tasks and decisions in one place, so everyone knows what's happening without another meeting."
      signup={{
        placeholder: "you@company.com",
        buttonLabel: "Get early access",
        note: "Free for teams of up to five. No card needed.",
        successMessage: "You're on the list. We'll be in touch soon.",
      }}
      logosLabel="Teams already planning in Lumen"
      logos={[
        { name: "Northwind" },
        { name: "Fieldwork" },
        { name: "KESTREL" },
        { name: "Halcyon" },
        { name: "Paperline" },
        { name: "Orbital" },
      ]}
      className="rounded-3xl border bg-background"
    />
  )
}

```
