Components

Matrix Rain

The classic Matrix digital rain as a React component: falling katakana and digits drawn on a high-DPI <canvas>, with configurable color, font size, speed, trail fade and characters. Drop it into any container as an animated hacker background — it fills its parent and pauses itself when off-screen.

  • Canvas 2D
  • devicePixelRatio aware
  • Fills its parent
  • Pauses off-screen
  • prefers-reduced-motion

Incident resolved

Installation

$ npx shadcn@latest add https://duskui.com/r/matrix-rain.json

The rain is absolute inset-0, so give its container relative (and a height). The canvas is transparent: the trails fade to whatever background is behind it.

Usage

hero.tsx
import { MatrixRain } from "@/components/dusk/hacker/matrix-rain"

export function Hero() {
  return (
    <section className="relative h-[480px] bg-black">
      <MatrixRain />
      <h1 className="relative">Wake up, Neo</h1>
    </section>
  )
}

Examples

Colors, size & characters

Any CSS color (theme variables too), a bright headColor, smaller or larger fontSize, speed, fade for trail length and custom characters — like binary.

Pause & mask

paused freezes the current frame without restarting. Style the layer with className — here a mask fades it out toward the bottom.

API Reference

Also accepts any <div> prop for the wrapping layer.

PropTypeDefaultDescription
colorstring"var(--color-primary)"Glyph color. Any CSS color, including theme variables.
headColorstring"#eafff6"Color of the leading glyph of each stream.
fontSizenumber16Glyph size in px; also the column width.
speednumber1Speed multiplier.
fadenumber0.08Trail fade per tick, 0–1. Lower means longer trails.
densitynumber0.4How busy the rain is, 0–1.
charactersstringkatakana + 0–9Characters to rain.
pausedbooleanfalseFreeze the current frame.

Accessibility

  • The canvas is purely decorative: aria-hidden and pointer-events-none, so content on top stays clickable and readable.
  • Animation stops while the rain is off-screen or the tab is hidden, and the animation frame is cancelled on unmount.
  • With prefers-reduced-motion a single still frame is drawn instead of the animation.
  • Glyphs move but never flash; keep enough contrast for text placed on top (e.g. a dark gradient behind headings).
  • Rendering uses a fixed 30 ticks per second, so it looks the same on 60 Hz and 120 Hz screens and never re-renders React.