Skip to content

UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.

2.1 KB
Raw Blame
---
title: Glyph Matrix
date: 2026-06-12
description: An animated grid of subtly shifting glyphs on a canvas, with a theme-aware color driven by the consumer.
author: magicui
published: true
---

<ComponentPreview name="glyph-matrix-demo" />

## Installation

<Tabs defaultValue="cli">

<TabsList>
  <TabsTrigger value="cli">CLI</TabsTrigger>
  <TabsTrigger value="manual">Manual</TabsTrigger>
</TabsList>
<TabsContent value="cli">

```bash
npx shadcn@latest add @magicui/glyph-matrix
```

</TabsContent>

<TabsContent value="manual">

<Steps>

<Step>Copy and paste the following code into your project.</Step>

<ComponentSource name="glyph-matrix" />

<Step>Update the import paths to match your project setup.</Step>

</Steps>

</TabsContent>

</Tabs>

## Usage

```tsx showLineNumbers
import { GlyphMatrix } from "@/registry/magicui/glyph-matrix"
```

```tsx showLineNumbers
<div className="border-border bg-background h-[400px] w-full overflow-hidden rounded-lg border">
  <GlyphMatrix />
</div>
```

## Props

| Prop           | Type     | Default          | Description                                  |
| -------------- | -------- | ---------------- | -------------------------------------------- |
| `glyphs`       | `string` | `"01·•+*/\\<>="` | Characters to randomly pick from.            |
| `cellSize`     | `number` | `14`             | Cell size in pixels and font size.           |
| `mutationRate` | `number` | `0.04`           | Probability a cell mutates each tick.        |
| `interval`     | `number` | `90`             | Tick interval in milliseconds.               |
| `className`    | `string` | `-`              | Classes applied to the canvas element.       |
| `fadeBottom`   | `number` | `0.6`            | Fade strength toward the bottom of the grid. |
| `color`        | `string` | `"#6B7280"`      | Glyph color (any CSS color).                 |

## Notes

The component draws with the `color` prop, which accepts any CSS color (hex, `rgb()`, `hsl()`, `oklch()`, ...) and is normalized through canvas before drawing. For light/dark support, drive `color` from the consumer — e.g. with `next-themes` as shown in the demo above.