A Matrix-style code rain behind a developer landing page hero: one canvas, strings that scroll at their own speed, colour from CSS, and a frame loop that knows when to stop. Plus a live request log and a copy-the-command button. Free component inside.
Developers judge a developer tool's website fast, and they judge it by looking for code. A stock photo of a laptop tells them nothing. An illustration of a rocket tells them less. What they want to see in the first three seconds is: what would I actually write, and does it work?
So for a made-up webhooks product called Hookvane, I built a hero section where everything speaks code: the snippet you'd write, a live log of requests landing under it, the install command as a button, and behind all of it, columns of lime code falling slowly down the screen.
This post shows how it's built in React, with the real code, focusing on the code rain: a Matrix-style canvas animation in about 25 lines of drawing, themed by CSS, and cheap enough to leave running behind a hero. The component is free at the end.
What's in the hero
Hookvane: "Webhooks that never miss."
- A tag line in lime mono: "v2.4 · Now with replay"
- The headline, white and lime, in Geist
- "Receive, verify and retry every webhook from 200+ providers. One endpoint, typed events, zero dropped deliveries."
- Two square, monospaced buttons: Get an API key (solid lime) and Read the docs (outlined)
- An install chip:
$ npm i @hookvane/sdkwith a copy button - A mono facts line: 12.4k GitHub stars · 99.99% delivered · SOC 2 Type II
- A row of client logos: "Delivering webhooks for"
- On the right: a code pane,
listen.ts, with a "live" dot, and under it a log of requests arriving - Behind everything: the code rain
The palette is two colours: zinc-950 black and Tailwind's lime-300. Geist for the headline, JetBrains Mono for every detail.
1. The code rain: the model
Here's the idea. Split the canvas into columns 18 px wide. Give each column:
- a string of 48 random code characters (hex digits and code punctuation), which repeats down the screen,
- a speed in lines per second, different for every column,
- a start offset, so they don't all line up.
const COLUMN_PX = 18;
const LINE_PX = 18;
const FPS = 24;
const GLYPHS = "0123456789abcdef{}[]()<>=/;:*+-_$#";
// A column's string is this many glyphs long; it repeats down the screen.
const STRING_LENGTH = 48;
function makeColumns(count: number): Column[] {
return Array.from({ length: count }, () => ({
glyphs: Array.from({ length: STRING_LENGTH }, randomGlyph),
speed: 0.6 + Math.random() * 1.8,
start: Math.random() * STRING_LENGTH,
}));
}
The glyph set is deliberate. Classic code rain uses katakana; for a developer tool, hex digits and brackets look like real code, so the background reads as "data flowing" rather than "film reference".
Speeds run from 0.6 to 2.4 lines per second. Slow, on purpose: this is a background. Fast rain behind a headline is exhausting to read over.
2. Drawing a frame
Each frame, every column draws one character per row. Which character goes in which row depends on how far the column has travelled:
columns.current.forEach((column, index) => {
const travelled = column.start + time * column.speed;
const shift = (travelled % 1) * LINE_PX;
for (let row = 0; row < rows; row += 1) {
const position = (row - Math.floor(travelled) + STRING_LENGTH * 1000) % STRING_LENGTH;
// Brightest at the head of the run (position 0), fading out along it.
context.globalAlpha = Math.max(0, 0.55 - position / STRING_LENGTH) * 0.7;
context.fillText(column.glyphs[position], index * COLUMN_PX, row * LINE_PX + shift);
}
if (Math.random() < 0.05) column.glyphs[Math.floor(Math.random() * STRING_LENGTH)] = randomGlyph();
});
Four details make it look right:
The string moves, not the characters. travelled is how many lines the column has moved since it started. Subtracting its whole part from the row picks which character of the string sits in that row, so the string slides down the screen. The + STRING_LENGTH * 1000 keeps the number positive before the modulo, because JavaScript's % returns negative results for negative numbers.
Smooth, not steppy. The fractional part of travelled becomes a pixel shift, so the whole column glides between lines instead of jumping 18 px at a time.
A head and a tail. Alpha is 0.55 - position / 48, so position 0 (the head) is brightest and it fades along the string, hitting zero a bit past halfway. Then the string repeats, so each column has bright heads arriving at regular gaps. The * 0.7 keeps even the brightest characters quiet.
It flickers like a live stream. Each frame, each column has a 5% chance of swapping one character. It's subtle, but static strings sliding down look like wallpaper; changing ones look like data.
3. Colour and font from CSS
This is my favourite part:
const style = getComputedStyle(context.canvas);
context.clearRect(0, 0, width, height);
context.fillStyle = style.color;
context.font = `12px ${style.fontFamily}`;
A canvas normally ignores CSS. But the <canvas> element itself still has a computed color and font-family. So the rain reads them, and you theme it with ordinary Tailwind classes:
<CodeRain className="absolute inset-0 -z-10 size-full mask-radial-from-transparent mask-radial-from-25% mask-radial-to-black mask-radial-to-90% font-code text-lime-300" />
text-lime-300 makes it lime. font-code makes it JetBrains Mono. Switch to text-sky-400 and it's blue. No props, no colour strings in the canvas code.
The mask in that class list matters too: a radial mask that's transparent from the centre out to 25% and fully visible from 90%. The rain fades out toward the middle of the hero, so it frames the content instead of fighting it.
4. A frame loop that knows when to stop
The drawing runs inside a reusable hook, useCanvasLoop, which handles everything that makes canvas animations expensive or janky:
// Runs `draw` on the canvas at most `fps` times a second. It stops while the canvas is off screen
// or the tab is hidden, and for visitors who ask for reduced motion it draws one still frame.
What it does:
-
Caps the frame rate. The rain asks for 24 fps.
requestAnimationFramestill ticks at the display's rate, but the hook skips drawing until 1/24 s has passed. On a 120 Hz screen that's 80% less work, and slow rain looks identical at 24 fps. - Sharp but not wasteful. It sizes the canvas to its box times the device pixel ratio, capped at 2: sharp on retina, without paying for 3× pixels on phones that have them.
-
Stops when nobody can see it. An
IntersectionObserverpauses it when the hero scrolls away, and it skips frames while the tab is hidden. -
Resizes itself. A
ResizeObserverrefits the canvas when the layout changes, and the rain makes a new set of columns when the count changes. - Reduced motion. It draws one still frame and never starts the loop.
The hook keeps the latest draw in a ref, so the loop never restarts when the component re-renders.
5. A log that lands one request at a time
Under the code pane, a log shows requests arriving: POST /hooks/github/push 200 41ms, then Stripe, and so on. It's driven by a small counting hook:
const LOG_STEP_MS = 1300;
const LOG_HOLD_MS = 2600;
const count = useCycleCount(requests.length, isRunning, { stepMs: LOG_STEP_MS, holdMs: LOG_HOLD_MS });
useCycleCount counts 1, 2, 3… up to the number of requests, one every 1.3 seconds, holds the full list for 2.6 seconds, then starts over. The log shows the first count requests, newest on top. Each row enters with AnimatePresence (fading in from 8 px above) and the rows below slide down with Motion's layout prop.
For reduced motion, the hook returns the full count straight away, so the whole log is visible and nothing moves.
6. The install command as a button
The second call to action for a developer tool isn't "Learn more". It's the one command that gets them started:
<button type="button" onClick={() => copy(command)} aria-label={`Copy command: ${command}`}>
<span aria-hidden className={style.prompt}>$</span>
<span className="truncate">{command}</span>
...
<span role="status" className="sr-only">{isCopied ? "Copied" : ""}</span>
</button>
Click it and the copy icon turns into a lime check for 1.6 seconds. A hidden status region says "Copied" to screen readers, and the button's label tells them what it copies. In the terminal style, the chip is square with a zinc border that turns lime on hover.
Design decisions
Code is the illustration. The snippet, the log and the rain are all code. For developers, that's the most persuasive picture you can show.
Two colours. Black and acid lime, nothing else. Lime marks the accent word, the primary button, the method names in the log and the "live" dot.
Square everything. No rounded corners on buttons or panes. Monospaced, uppercase, widely tracked button labels. It looks like a terminal because the audience lives in one.
Proof in mono. "12.4k GitHub stars · 99.99% delivered · SOC 2 Type II" in small mono type under the buttons: the three questions a developer asks, answered before they ask.
Frequently asked questions
Is this code rain hero free?
Yes. The whole hero is free to copy: the code rain canvas, the code pane, the request log, the command chip and the nav.
What is it built with?
React, Next.js, Tailwind CSS and Motion (Framer Motion), with lucide-react icons. The rain is plain Canvas 2D, no library.
Will the canvas animation slow my page down?
It's built not to. It draws at most 24 times a second, caps the pixel ratio at 2, stops when off screen or in a hidden tab, and draws a single frame for reduced motion.
How do I change the colour of the code rain?
Change the text colour class on the canvas, for example text-sky-400 instead of text-lime-300. The canvas reads its colour and font from CSS.
Can I use katakana like the classic effect?
Yes. Change the GLYPHS string to any characters you like. Make sure your font has them.
Does it work on mobile?
Yes. The layout stacks to one column, the canvas resizes with its box, and the rain keeps its 18 px columns, so phones just get fewer of them.
Get the component
The whole hero is free to copy: developer hero section with code rain →
I'm building a free library of animated React components and landing pages at ui.deliverwebsite.com. Follow for one new component every day.
More from me: Instagram · X · YouTube · Medium · Substack · Reddit · Pinterest · Free UI library
Top comments (0)