A hexagonal grid that lights each cell under the pointer.
Installation
Install the packages
npm install @prequelui/react motion@prequelui/react reuses the primitive library your components already depend on.
Add the component
npx shadcn@latest add https://animate.prequelui.terravidhal.me/r/hexagon.jsonnpx shadcn@latest add https://animate.prequelui.terravidhal.me/r/hexagon.json
Turn on the motion
npx @prequelui/cli@latest animate hexagonThe 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.
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.
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
| Prop | Type | Default |
|---|---|---|
| hexagonSize | number | 46 |
| hexagonMargin | number | 3 |
| speed | number | 1 |
| paused | boolean | false |
| className | string | — |