Background

Hexagon

A hexagonal grid that lights each cell under the pointer.

hexagon.tsx

Installation

1

Install the packages

npm install @prequelui/react motion

@prequelui/react reuses the primitive library your components already depend on.

2

Add the component

npx shadcn@latest add https://animate.prequelui.terravidhal.me/r/hexagon.json

npx shadcn@latest add https://animate.prequelui.terravidhal.me/r/hexagon.json

3

Turn on the motion

npx @prequelui/cli@latest animate hexagon

The CLI finds the component through components.json, swaps the import and removes the CSS animation classes that Motion replaces.

Usage

Import the component and compose it exactly like the primitive it wraps. Motion is enabled by default; the tempo prop scales every duration and softens every spring.

hexagon.tsx
import { HexagonBackground } from "@/components/prequelui/backgrounds/hexagon";

export default function Demo() {
  return (
    <div className="relative h-96 overflow-hidden rounded-xl">
      <HexagonBackground />
    </div>
  );
}
import { Hexagon } from "@/components/prequelui/hexagon";

export function Variant() {
  return (
    <Hexagon tempo={1.2}>
      …
    </Hexagon>
  );
}

Animation

The grid is measured from the container and rebuilt only when its size changes. Each cell is a clipped hexagon with an edge layer and a face layer; hovering lights both instantly, and the cell cools down over one second when the pointer leaves.

  • Default cell: 46 px wide, 1.1 aspect ratio, 3 px seam.
  • Rows overlap by a quarter of the cell height so the seams stay even.
  • Hover transition is 0 ms; the return transition is 1000 ms divided by speed.
  • The grid is decorative: it has no tab stops and no accessible name.
46 px cell1 s cooldowninstant hoverResizeObserver grid

API Reference

Each part accepts the usual HTML props in addition to the motion props below. No accessibility prop is hidden behind the animation layer.

HexagonBackground

PropTypeDefault
hexagonSizenumber46
hexagonMarginnumber3
speednumber1
pausedbooleanfalse
classNamestring—

Built by Vidhal. The source is available on GitHub.

Last updated: 11/17/2026