Matrix Code Rain

Matrix-style falling code rain rendered on canvas, usable as a background.

Matrix Code Rain renders the classic falling green character columns on an HTML canvas, with katakana, digits, and symbols cycling as they drop. Density, fall speed, character set, and colors are props, and it scales to fill any container or the whole page background. Built with React and Tailwind CSS. Works well behind hero sections, on hacker themed landing pages, and anywhere you want an instantly recognizable retro terminal mood.

Installation

Usage

import { MatrixCodeRain } from "@/components/ui/matrix-code-rain";
export default function MyComponent() {
  return (
    <div className="relative h-[400px] w-full overflow-hidden">
      <MatrixCodeRain />
 
      {/* Optional overlay content */}
      <div className="absolute inset-0 flex items-center justify-center">
        <div className="bg-black/50 p-6 rounded-lg text-white">
          <h1 className="text-3xl font-bold">Your Content Here</h1>
        </div>
      </div>
    </div>
  );
}

Props

PropTypeDefaultDescription
colorstring"#00ff00"The color of the matrix characters
charsetstring"0123#!$^&456789ABCDEFRLY"The set of characters to display in the animation
fontSizenumber16The size of the characters in pixels
fpsnumber20Frames per second - controls animation speed
opacitynumber0.05The opacity of the fade effect (0-1)
fullScreenbooleanfalseWhether to display the effect as a fullscreen background
widthstring"100%"The width of the container when not in fullscreen mode
heightstring"400px"The height of the container when not in fullscreen mode