# Horizon Grid

> A retro perspective grid rolling toward a glowing horizon, synthwave style.

Category: Backgrounds · Free · Updated 2026-10-20 · Live demo: https://www.motionkitui.com/components/horizon-grid

## When to use it

Retro, synthwave, gaming and music themes, launch pages and event sites.

## How it works

A grid of lines is painted with CSS gradients on a floor that tips away under a CSS perspective. Moving the background-position by exactly one square loops it seamlessly, so the grid rolls towards you forever. The far edge fades into a glowing horizon line.

## Installation

```bash
npx shadcn@latest add https://www.motionkitui.com/r/horizon-grid.json
```

Or copy `components/motionkit/horizon-grid.tsx` below. Requires react, motion and Tailwind CSS v4. Free for personal projects; commercial use needs MotionKit Plus (https://www.motionkitui.com/pricing).

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `cell` | `number` | `40` | Grid square size in pixels. |
| `angle` | `number` | `70` | Tilt of the floor in degrees. Higher looks flatter. |
| `duration` | `number` | `1.2` | Seconds for the grid to travel one square toward the viewer. |
| `color` | `string` | `"#2E9098"` | Line and horizon colour. |

## Accessibility

- **Keyboard: Not applicable.** A decorative background with nothing to focus.
- **Screen readers: Pass.** The grid and horizon are hidden from assistive tech.
- **Reduced motion: Partial.** The grid holds still for reduced-motion users. It loops forever otherwise, so if it sits beside other content for more than 5 seconds, WCAG 2.2.2 asks you to add a pause control.
- **Colour contrast: Pass.** The grid only fills the lower half, leaving the top half plain for your text.

## Source

```tsx
"use client";

import type { ReactNode } from "react";
import { motion, useReducedMotion } from "motion/react";

type HorizonGridProps = {
  children?: ReactNode;
  /** Grid square size in pixels. */
  cell?: number;
  /** Tilt of the floor in degrees. Higher looks flatter. */
  angle?: number;
  /** Seconds for the grid to travel one square toward the viewer. */
  duration?: number;
  /** Line and horizon colour. */
  color?: string;
  className?: string;
};

export function HorizonGrid({
  children,
  cell = 40,
  angle = 70,
  duration = 1.2,
  color = "#2E9098",
  className = "",
}: HorizonGridProps) {
  const reduceMotion = useReducedMotion();

  return (
    <div className={`relative isolate overflow-hidden bg-[#0C1010] ${className}`}>
      <div aria-hidden className="absolute inset-x-0 bottom-0 -z-10 h-[45%] overflow-hidden [perspective-origin:50%_0%] [perspective:200px]">
        {/* the floor hinges on the bottom edge and tips away; moving the pattern by exactly one square loops seamlessly */}
        <motion.div
          className="absolute -inset-x-full bottom-0 h-[400%]"
          style={{
            rotateX: angle,
            originY: 1,
            backgroundImage: `linear-gradient(to right, ${color} 1px, transparent 1px), linear-gradient(to bottom, ${color} 1px, transparent 1px)`,
            backgroundSize: `${cell}px ${cell}px`,
            opacity: 0.55,
          }}
          animate={reduceMotion ? undefined : { backgroundPosition: ["0px 0px", `0px ${cell}px`] }}
          transition={{ duration, repeat: Infinity, ease: "linear" }}
        />
        {/* fade the far edge into the horizon */}
        <div className="absolute inset-0 bg-[linear-gradient(to_bottom,#0C1010,transparent_60%)]" />
      </div>
      {/* the horizon line and its glow */}
      <div
        aria-hidden
        className="absolute inset-x-0 top-[55%] -z-10 h-px"
        style={{ background: `linear-gradient(to right, transparent, ${color}, transparent)`, boxShadow: `0 0 40px 6px ${color}55` }}
      />
      {children}
    </div>
  );
}
```
