Perspective grid
A synthwave grid floor: a perspective-rotated plane whose lines run to the horizon and stream toward you on a transform loop; horizon fog swallows the edge, a slider sets the speed and the lines glow in the dark.
Real scenarios
The component as it is used in a product — not a specimen grid.
A floor that streams toward you
One rotateX(58°) plane, one repeating 64px grid and a seamless one-cell translate loop — the grid rushes at the viewer without ever re-laying pixels. The fog band eats the horizon, the sun sinks half behind it, and the slider retunes the tempo from cruising to warp. Flat grey in daylight, fuchsia glow after dark.
Thirty-two years of synth, one horizon
From Tokyo nights to Toronto dawns — Nightdrive FM streams the classics and the fresh presses back to back, 24 hours a day.
rotateX(58°) plane · 64px cells · seamless one-cell translate loop · drop-shadow glow in dark · pauses off screen
Important props
| Prop | Type | Default | What it does |
|---|---|---|---|
| --ambg-tile | length | '64px' | The grid cell; the loop travels exactly one cell so the seam never shows. |
| speed | seconds | '1.6s / cell' | The slider pulls the period from 3s (calm) down to .6s (fast). |
| fog | gradient | '55%' | The fog band above the floor hides the horizon and fades the grid’s far start. |
| glow | color | '#f0abfc' | In the dark theme the lines glow fuchsia through a soft shadow; in light they sit flat and grey. |
Snippet
<section class="ambg" style="--ambg-dur: 1.6s" data-running="true">
<div class="ambg-floor" aria-hidden="true"><i class="ambg-lines"></i></div>
<div class="ambg-fog" aria-hidden="true"></div>
<h2>Nightdrive, the retro station</h2>
<p>32 years of synth, one speed slider away.</p>
</section>
<style>
.ambg { position: relative; overflow: clip; border-radius: 1.25rem; min-block-size: 22rem;
display: grid; place-content: center; text-align: center;
background: #171228; color: #fdf4ff; perspective: 420px; }
.ambg-floor { position: absolute; inset-inline: -60%; inset-block-start: 52%; block-size: 150%;
transform: rotateX(58deg); transform-origin: 50% 0; }
.ambg-lines { position: absolute; inset-inline: 0; inset-block: -100% 0;
background-image: repeating-linear-gradient(to right, #f0abfc33 0 2px, transparent 2px 64px),
repeating-linear-gradient(to bottom, #f0abfc33 0 2px, transparent 2px 64px);
animation: ambg-run var(--ambg-dur) linear infinite; }
@keyframes ambg-run { to { translate: 0 64px; } }
.ambg-fog { position: absolute; inset-inline: 0; inset-block-start: 0; block-size: 55%;
background: linear-gradient(#171228 12%, transparent); }
.ambg[data-running='false'] .ambg-lines { animation-play-state: paused; }
</style>
// app/Pages/Nightdrive.jsx — Inertia (React) page; renders the React
// snippet below unchanged, with Inertia's Link wired into the provider.
import { Link } from '@inertiajs/react';
import { NabuXUIProvider } from '@nabuxai/ui-react';
import NightdriveHero from '@/components/NightdriveHero';
export default function Nightdrive() {
return (
<NabuXUIProvider locale="en" linkComponent={Link}>
<main className="nx-page">
<NightdriveHero />
</main>
</NabuXUIProvider>
);
}
// NightdriveHero.jsx — synthwave perspective grid with a speed slider
import { useEffect, useRef, useState } from 'react';
import '@nabuxai/ui-core/css';
export default function NightdriveHero() {
const [dur, setDur] = useState(1.6); // seconds per 64px cell
const [running, setRunning] = useState(true);
const sectionRef = useRef(null);
// Park the stream off screen; reduced motion freezes the floor.
useEffect(() => {
const io = new IntersectionObserver(
([e]) => setRunning(e.isIntersecting),
{ threshold: 0.15 },
);
io.observe(sectionRef.current);
return () => io.disconnect();
}, []);
return (
<>
<style>{`
.ambg { position: relative; overflow: clip; border-radius: 1.25rem; min-block-size: 22rem;
display: grid; place-content: center; text-align: center; background: #171228;
color: #fdf4ff; perspective: 420px; }
.ambg-floor { position: absolute; inset-inline: -60%; inset-block-start: 52%; block-size: 150%;
transform: rotateX(58deg); transform-origin: 50% 0; }
.ambg-lines { position: absolute; inset-inline: 0; inset-block: -100% 0;
background-image: repeating-linear-gradient(to right, #f0abfc4d 0 2px, transparent 2px 64px),
repeating-linear-gradient(to bottom, #f0abfc4d 0 2px, transparent 2px 64px);
animation: ambg-run var(--ambg-dur) linear infinite; }
@keyframes ambg-run { to { translate: 0 64px; } }
.ambg-fog { position: absolute; inset-inline: 0; inset-block-start: 0; block-size: 55%;
background: linear-gradient(#171228 12%, transparent); }
.ambg[data-running='false'] .ambg-lines { animation-play-state: paused; }
.ambg-copy { position: relative; padding: 2rem; }
.ambg-slider { display: flex; align-items: center; gap: .75rem; justify-content: center;
margin-block-start: 1.25rem; font-size: .8rem; color: #d8b4fe; }
.ambg-slider input { accent-color: #f0abfc; inline-size: min(14rem, 60vw); }
@media (prefers-reduced-motion: reduce) { .ambg-lines { animation: none; } }
`}</style>
<section className="ambg" data-running={running} ref={sectionRef}
style={{ ['--ambg-dur']: `${dur}s` }}>
<div className="ambg-floor" aria-hidden="true"><i className="ambg-lines" /></div>
<div className="ambg-fog" aria-hidden="true" />
<div className="ambg-copy">
<h2>Nightdrive, the retro station</h2>
<p>32 years of synth, streamed from Tokyo to Toronto.</p>
<label className="ambg-slider">
<span aria-hidden="true">🐢</span>
<input type="range" min="0.6" max="3" step="0.1" value={dur}
aria-label="Grid speed" onChange={(e) => setDur(+e.target.value)} />
<span aria-hidden="true">🚀</span>
</label>
</div>
</section>
</>
);
}
<!-- NightdriveHero.vue — synthwave perspective grid with a speed slider -->
<script setup lang="ts">
import { onBeforeUnmount, onMounted, ref } from 'vue';
import '@nabuxai/ui-core/css';
const dur = ref(1.6); // seconds per 64px cell
const running = ref(true);
const section = ref<HTMLElement | null>(null);
let io: IntersectionObserver | null = null;
// Park the stream off screen; reduced motion freezes the floor.
onMounted(() => {
io = new IntersectionObserver(([e]) => { running.value = e.isIntersecting; }, { threshold: 0.15 });
if (section.value) io.observe(section.value);
});
onBeforeUnmount(() => io?.disconnect());
</script>
<template>
<section ref="section" class="ambg" :data-running="running" :style="{ '--ambg-dur': `${dur}s` }">
<div class="ambg-floor" aria-hidden="true"><i class="ambg-lines" /></div>
<div class="ambg-fog" aria-hidden="true" />
<div class="ambg-copy">
<h2>Nightdrive, the retro station</h2>
<p>32 years of synth, streamed from Tokyo to Toronto.</p>
<label class="ambg-slider">
<span aria-hidden="true">🐢</span>
<input v-model.number="dur" type="range" min="0.6" max="3" step="0.1" aria-label="Grid speed" />
<span aria-hidden="true">🚀</span>
</label>
</div>
</section>
</template>
<style scoped>
.ambg { position: relative; overflow: clip; border-radius: 1.25rem; min-block-size: 22rem;
display: grid; place-content: center; text-align: center; background: #171228;
color: #fdf4ff; perspective: 420px; }
.ambg-floor { position: absolute; inset-inline: -60%; inset-block-start: 52%; block-size: 150%;
transform: rotateX(58deg); transform-origin: 50% 0; }
.ambg-lines { position: absolute; inset-inline: 0; inset-block: -100% 0;
background-image: repeating-linear-gradient(to right, #f0abfc4d 0 2px, transparent 2px 64px),
repeating-linear-gradient(to bottom, #f0abfc4d 0 2px, transparent 2px 64px);
animation: ambg-run var(--ambg-dur) linear infinite; }
@keyframes ambg-run { to { translate: 0 64px; } }
.ambg-fog { position: absolute; inset-inline: 0; inset-block-start: 0; block-size: 55%;
background: linear-gradient(#171228 12%, transparent); }
.ambg[data-running='false'] .ambg-lines { animation-play-state: paused; }
.ambg-copy { position: relative; padding: 2rem; }
.ambg-slider { display: flex; align-items: center; gap: .75rem; justify-content: center;
margin-block-start: 1.25rem; font-size: .8rem; color: #d8b4fe; }
.ambg-slider input { accent-color: #f0abfc; inline-size: min(14rem, 60vw); }
@media (prefers-reduced-motion: reduce) { .ambg-lines { animation: none; } }
</style>
<!-- NightdriveHero.svelte — synthwave perspective grid with a speed slider -->
<script lang="ts">
import { onMount } from 'svelte';
import '@nabuxai/ui-core/css';
let dur = $state(1.6); // seconds per 64px cell
let running = $state(true);
let section: HTMLElement;
// Park the stream off screen; reduced motion freezes the floor.
onMount(() => {
const io = new IntersectionObserver(([e]) => { running = e.isIntersecting; }, { threshold: 0.15 });
io.observe(section);
return () => io.disconnect();
});
</script>
<section bind:this={section} class="ambg" data-running={running} style={`--ambg-dur:${dur}s`}>
<div class="ambg-floor" aria-hidden="true"><i class="ambg-lines"></i></div>
<div class="ambg-fog" aria-hidden="true"></div>
<div class="ambg-copy">
<h2>Nightdrive, the retro station</h2>
<p>32 years of synth, streamed from Tokyo to Toronto.</p>
<label class="ambg-slider">
<span aria-hidden="true">🐢</span>
<input type="range" min="0.6" max="3" step="0.1" aria-label="Grid speed"
bind:value={dur} oninput={(e) => (dur = +e.currentTarget.value)} />
<span aria-hidden="true">🚀</span>
</label>
</div>
</section>
<style>
.ambg { position: relative; overflow: clip; border-radius: 1.25rem; min-block-size: 22rem;
display: grid; place-content: center; text-align: center; background: #171228;
color: #fdf4ff; perspective: 420px; }
.ambg-floor { position: absolute; inset-inline: -60%; inset-block-start: 52%; block-size: 150%;
transform: rotateX(58deg); transform-origin: 50% 0; }
.ambg-lines { position: absolute; inset-inline: 0; inset-block: -100% 0;
background-image: repeating-linear-gradient(to right, #f0abfc4d 0 2px, transparent 2px 64px),
repeating-linear-gradient(to bottom, #f0abfc4d 0 2px, transparent 2px 64px);
animation: ambg-run var(--ambg-dur) linear infinite; }
@keyframes ambg-run { to { translate: 0 64px; } }
.ambg-fog { position: absolute; inset-inline: 0; inset-block-start: 0; block-size: 55%;
background: linear-gradient(#171228 12%, transparent); }
.ambg[data-running='false'] .ambg-lines { animation-play-state: paused; }
.ambg-copy { position: relative; padding: 2rem; }
.ambg-slider { display: flex; align-items: center; gap: .75rem; justify-content: center;
margin-block-start: 1.25rem; font-size: .8rem; color: #d8b4fe; }
.ambg-slider input { accent-color: #f0abfc; inline-size: min(14rem, 60vw); }
@media (prefers-reduced-motion: reduce) { .ambg-lines { animation: none; } }
</style>