webdevpuneet.com

Retro Grid — Free HTML CSS Synthwave Hero Background Snippet

Retro Grid · Heroes · Plain HTML, CSS & JS · Live preview

CategoryHeroes

Copy & paste

Source Code

<section class="rg-hero">
  <div class="rg-grid" aria-hidden="true"><div class="rg-plane"></div></div>
  <div class="rg-sun" aria-hidden="true"></div>
  <div class="rg-content">
    <span class="rg-tag">★ SYNTHWAVE</span>
    <h1>Outrun the night</h1>
    <p>An animated neon grid floor racing toward the horizon — pure CSS perspective.</p>
  </div>
</section>

Extend with AI

Take This Snippet Further With AI

The AI prompt for this one is for Patreon supporters ($3 a month, 7 days free), along with a site with no ads. Supporters enter the passcode once and it is remembered in this browser.

· Become a supporter

What's included

Features

CSS perspective floor
rotateX plus a low perspective recede the grid.
Seamless forward race
background-position shifts one tile and loops.
Gradient grid lines
Two layered gradients, no image.
Masked retro sun
Slats banded by a mask gradient.
Outrun palette
Indigo-to-magenta sky with neon type.
Glowing headline
Clipped gradient text with a soft glow.
Battery-aware
Animation pauses when the tab is hidden.
Runtime speed API
A tiny helper retunes the run speed.

About this UI Snippet

Retro Grid — Animated Synthwave Perspective Floor

Screenshot of the Retro Grid snippet rendered live

The retro grid is the 80s synthwave staple: a glowing neon grid floor that recedes to a horizon and races endlessly toward the viewer, lit by a striped retro sun. It is the backdrop of choice for vaporwave, outrun, and game-themed sites. This snippet builds the whole scene with pure CSS perspective and a couple of optional lines of JavaScript — no canvas, no images.

The perspective floor

The grid lives in a container with perspective: 240px and a child plane that is rotated flat with transform: rotateX(72deg) and transform-origin: bottom. That low perspective value combined with the steep rotation tips the plane almost flat and exaggerates the foreshortening, so the lines compress toward a vanishing point — the signature receding-floor look. The plane itself is just two layered linear-gradient backgrounds (pink horizontals, cyan verticals) tiled at 44px, the same graph-paper trick used for any CSS grid, here viewed in 3D.

Making it race forward

Animating the plane toward the viewer is a one-line keyframe: rgRun shifts background-position down by exactly one tile (44px) over 1.6 seconds and loops. Because the grid pattern repeats every 44px, moving by one full cell lands on an identical pattern, so the loop is seamless — the lines appear to stream continuously toward you with no visible jump. The plane is oversized (inset: -60% at the top) so the scrolling lines fill the perspective without revealing an edge near the horizon.

The retro sun

The sun is a circle filled with a vertical yellow-to-pink gradient and a soft glowing box-shadow. Its iconic horizontal slats come from an ::after pseudo-element: a repeating-linear-gradient of background-colored bars, masked so the stripes only appear across the lower half (mask: linear-gradient(transparent 55%, #000 55%)). That mask is what gives the classic synthwave sun its half-banded look without drawing each stripe by hand.

The color story

A vertical background gradient runs from deep indigo at the top through magenta to near-black at the bottom, so the sky glows behind the sun and darkens toward the grid. The headline uses a top-down background-clip: text gradient with a soft text-shadow glow, and the tag and copy use neon cyan and violet — all the hallmarks of the outrun palette. Everything is CSS, so recoloring the whole scene is a handful of values.

The optional script

The animation is entirely CSS, but two small JavaScript conveniences are included: a visibilitychange listener pauses the grid when the tab is hidden to spare the GPU, and a tiny window.retroGrid.speed(seconds) helper lets you retune the run speed at runtime (for example, to accelerate on a button press). Neither is required for the effect to work.

Customizing it

Change the perspective and rotateX to steepen or flatten the floor, adjust the 44px tile size for a denser or wider grid, retime rgRun for a faster or slower race, recolor the line gradients and sun, or move the horizon by resizing the grid container. Pair it with an aurora text headline or a pulse button for a complete retro hero.

Step by step

How to Use

  1. 1
    Paste HTML, CSS, and JSA neon grid floor and a striped sun fill the hero.
  2. 2
    Watch it raceThe grid lines stream endlessly toward the horizon.
  3. 3
    Note the sunHorizontal slats band its lower half, synthwave style.
  4. 4
    Switch tabsThe grid pauses while hidden to save the GPU.
  5. 5
    Retune the speedCall window.retroGrid.speed(seconds) at runtime.
  6. 6
    Recolor the sceneEdit the gradient and sun colors.

Real-world uses

Common Use Cases

Synthwave landing pages
Pair with an aurora text headline over a neon grid floor that races toward the horizon in CSS perspective.
Game and arcade sites
Set the mood behind a pulse button, with a looping background-position shift producing a seamless forward race.
Music and DJ pages
Provide a retro backdrop for an app hero, with a striped sun built from a mask gradient.
Event microsites
Frame a shiny text announcement against a vaporwave scene made from two layered gradients and no images.
Retro portfolios
Offer an 80s alternative to a minimal hero, and learn rotateX with low perspective as a reference for receding planes.
Related: Split-Screen Hero with Embedded Signup Form
See the Split-Screen Hero with Embedded Signup Form for a related heroes pattern worth pairing with this one.

Got questions?

Frequently Asked Questions

The grid container has perspective: 240px and its child plane is rotated with rotateX(72deg) and transform-origin: bottom. The low perspective value plus the steep rotation tips the plane nearly flat and exaggerates the foreshortening, so the gridlines compress toward a vanishing point — the classic receding-floor look, all in CSS.

The rgRun keyframe shifts the plane background-position down by exactly one 44px tile and loops. Because the grid pattern repeats every 44px, moving by one full cell lands on an identical pattern, so the restart is invisible and the lines appear to stream continuously toward the viewer.

The sun is a circle with a vertical yellow-to-pink gradient and a glowing box-shadow. Its horizontal slats come from an ::after repeating-linear-gradient of background-colored bars, masked with a linear-gradient so the stripes only show across the lower half. The mask gives the iconic half-banded sun without drawing each stripe manually.

Not very — it animates only background-position on one element, which the compositor handles efficiently. A visibilitychange listener also pauses it when the tab is hidden to spare the GPU. For very low-end targets you can slow the keyframe or enlarge the tile size to reduce the number of lines.

The scene is pure CSS, so drop the markup into a component and keep the classes. Add the visibilitychange listener in a mount effect with cleanup, and expose the speed control as a prop that sets the animation-duration via a ref or inline style instead of the global helper. In Tailwind, build the plane with a bg-[linear-gradient(...)] arbitrary value and define the run keyframe in the config.