shadcn.io is not affiliated with official shadcn/ui
Matrix fills a box with digital rain: columns of katakana and digits fall at their own pace, each led by a bright glyph that flickers, with a trail that fades out behind it. The columns are laid out on the server from a fixed seed and moved by CSS keyframes, so the rain runs no script and looks the same on every load. It's the film's green by default, near-white heads on a dark page and deep green ones on a light page.
Use it behind a hero, a sign-in screen or a terminal-style card. For the same screen texture as blinking cells, use Flickering Grid; for a CRT that tears and glitches, Glitch; for falling streaks that read as weather rather than code, Rain.
Installation
Usage
import { Matrix } from "@/components/ui/matrix";<Matrix className="min-h-[420px]">
<h1>Zero trust, all the way down</h1>
</Matrix>Matrix is a container: put your content inside and the rain falls behind it. It fills the box you give it, so set its height (min-h-[420px]), or className="fixed inset-0" to cover the whole page. The rain is transparent, so the box's own background shows through: add bg-black for the film's black screen.
Demos
Theme colours
color sets the rain and headColor the leading glyph, any CSS colour. Here they're the theme's --muted-foreground and --foreground, so the rain is grey ink on a light page and grey light on a dark one; color="var(--primary)" tints it with your brand.
Inside a card
A sparse, slow rain in a small box: size={12} for smaller glyphs and narrower columns, density={0.5} to leave half the columns empty, and speed={0.6}. columns={32} renders only the 32 columns a 384px card needs, so the page sends less HTML.
Accessibility
The rain is decoration: the whole layer is hidden from screen readers, ignores the pointer and can't be selected, so copying the page never picks up glyphs. With reduced motion every column stops where it is, a still frame of the rain rather than an empty box. Nothing flashes: a head changes shape a few times a second, never brightness. The trail sits behind your text at full strength, so keep text in the foreground colour and give a headline a soft scrim (such as a radial gradient in --background), or lower density to about 0.5 behind body text.
FAQ
What characters does it use?
Half-width katakana and the digits 0–9, mirrored as in the film. Pass charset for your own: "01" for binary, "0123456789ABCDEF" for hex, or any letters. Each character is one glyph. Wide glyphs (full-width or CJK) are wider than a column and touch their neighbours.
How do I change the speed?
speed multiplies every column's fall rate: 0.5 is slow and heavy, 2 a downpour. Each column keeps its own pace, from about 2.6 to 5.4 seconds a fall at speed 1, and its head flickers at the same rate whatever the speed. You can also set --matrix-speed from CSS.
How do I make it denser or sparser?
size sets the glyph size and the column width, 16px by default: smaller means more, thinner columns. density, from 0 to 1, leaves a share of the columns empty, chosen from the same seed, so a sparse rain looks the same on every load.
Can I change the colour?
Yes: color takes any CSS colour for the rain and headColor for the leading glyph (or set --matrix-color and --matrix-head from CSS). By default the head is the rain's colour mixed toward your theme's foreground, which makes it bright on a dark page and dark on a light one. On a dark section of a light page, such as bg-black, pass a light headColor too, like oklch(0.97 0.08 145).
Does it run JavaScript while it animates?
No. The columns are built when the page renders and CSS moves them: each column slides down on its own seeded duration, and its head steps through four glyphs. With reduced motion the rain stands still.
How many columns does it render?
Enough to cover a box 2560px wide: 160 columns at the default size, about 8 KB of HTML once compressed. Columns past the box's right edge are hidden by a container query, so only the ones you see animate. In a small box, pass columns with the number it needs (its width divided by size) to send less HTML.
API Reference
Matrix
<div> data-slot="matrix"
charset?string
The glyphs the rain draws from; each character is one glyph. Ark default: half-width katakana and the digits 0–9.
- Default
CHARSET
color?string
The rain's colour, any CSS colour. @default a signature green.
columns?number
The most columns it renders, from the left. The default covers a box 2560px wide; lower it for a small box, to send less HTML.
- Default
Math.ceil(2560 / size)
density?number
The share of columns that rain, from 0 to 1: lower it for a sparser rain behind body text.
- Default
1
fade?"none" | "radial" | "top" | "bottom"
Where the rain fades out: toward every edge, toward the top, toward the bottom, or nowhere.
- Type
"none" | "radial" | "top" | "bottom"- Default
"radial"
headColor?string
The leading glyph's colour, any CSS colour.
- Default
the rain's colour, mixed toward `var(--foreground)`
size?number
The glyph size and the column width, in pixels. @default 16.
- Default
16
speed?number
How fast it falls, as a multiplier: 0.5 is slow, 2 is fast. @default 1.
render?ReactElement | ((props: object, state: object) => ReactElement)
Replace the host element or compose it with another component.
- Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string
Merged with the part's classes.
--matrix-colorstring
The rain's colour (a signature green).
--matrix-headstring
The leading glyph's colour (the rain's, mixed toward --foreground).
--matrix-speedstring
How fast it falls, a multiplier (1).
Related
- Pro


The same screen texture, as blinking cells
- Pro


Digital corruption on a CRT screen
- Pro


Rain Background
WeatherThe same downward streaks, as weather
- Pro


Signals running along traces, also Tech
- Pro


A glowing phosphor trace on a scope
- Pro


The other 80s/cyber hero