A background component featuring an interactive hexagon grid.
Installation
Usage
import { HexagonBackground } from '@/components/animate-ui/backgrounds/hexagon';
export function Hero() {
return (
<section className="relative h-[480px] overflow-hidden">
<HexagonBackground className="absolute inset-0" />
</section>
);
}Animation
- A grid of hexagons that fills its container and recounts its cells when the container resizes.
- A hovered hexagon lights up instantly, and fades back over 1s when the pointer leaves, leaving a trail. Hover only applies to devices that can hover, so a tap doesn't leave a cell lit.
- Nothing loops, so there is nothing to pause.
- Reduced motion keeps the fade: it's a color change, not movement.
API Reference
HexagonBackground
| Prop | Type | Default |
|---|---|---|
hexagonSize? | number | 75 |
hexagonMargin? | number | 3 |
hexagonProps? | React.ComponentProps<'div'> | - |
...props? | React.ComponentProps<'div'> | - |
Credits
- Credits to Denis Klak for the inspiration