A background component featuring an interactive hexagon grid.
Installation
Usage
<script setup lang="ts">
import HexagonBackground from '@/components/animate-ui/backgrounds/hexagon/HexagonBackground.vue';
</script>
<template>
<section class="relative h-[480px] overflow-hidden">
<HexagonBackground class="absolute inset-0" />
</section>
</template>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 |
|---|---|---|
hexagon-size? | number | 75 |
hexagon-margin? | number | 3 |
hexagon-props? | HTMLAttributes | - |
...attrs? | HTMLAttributes | - |
Credits
- Credits to Denis Klak for the inspiration