Skip to content
WANCRAFT

E.109Backgrounds & Effects

ASCII Field

An animated ASCII-art field: noise, waves or rings sampled on a character grid and mapped to a density ramp.

NewReactCanvasTailwindadvanced

Overview

ASCII Field samples a field function — layered simplex noise, interfering sine waves or noise-warped concentric rings — at the centre of every character cell and maps the value onto a density ramp such as " .:-=+*#%@". Glyphs are pre-rendered once into a small atlas (one tinted copy per ramp step), so each frame is a batch of canvas blits instead of thousands of fillText calls, paced at ~30fps for an editorial, print-like rhythm. Dense characters can shift toward the accent colour; a mouse pointer brightens the field around it and clicks or taps send out a ripple. The canvas is DPR-aware, follows light and dark themes, pauses offscreen and in hidden tabs, and renders one still frame for reduced motion.

01Installation

Method 01 · Registry

CLI verified

Uses the shadcn CLI in a project initialised with shadcn init. Installs the file to components/ui/ascii-field.tsx and adds its dependencies.

npx shadcn@latest add https://wancraft.my/r/ascii-field.json

Method 02 · Copy and paste

  1. 1. No extra dependencies — React and Tailwind CSS only.
  2. 2. Copy the source from the Code tab into components/ui/ascii-field.tsx.
  3. 3. Import it and adjust props.
Dependencies
None
Peer
react ≥ 18, tailwindcss ≥ 4
Added
13 Oct 2026
Updated
—

02Usage

The default configuration. Change properties above to generate a tailored example in the Usage tab.

example.tsx
import { AsciiField } from "@/components/ui/ascii-field";

export function AsciiFieldExample() {
  return (
    <div className="relative h-80 w-full overflow-hidden rounded-xl">
      <AsciiField />
    </div>
  );
}

03Props

PropTypeDefaultDescription
charsetstring" .:-=+*#%@"Density ramp from empty to full. A leading space leaves low values blank.
cellSizenumber14Row height in px (min 6); column width follows the monospace glyph width.
speednumber1Animation speed multiplier; 0 freezes the field and idles the loop.
mode"noise" | "waves" | "rings""noise"Field function sampled per cell.
colorizebooleantrueTint the densest characters toward the accent colour.
accentstring"#FF7448"Accent for dense characters (any CSS colour).
interactivebooleantrueMouse/pen hover brightens the field; clicks and taps send a ripple.
childrenReactNode—Optional content layered above the field.
...propsHTMLAttributes<HTMLDivElement>—Forwarded to the root, which is absolute inset-0 — place it inside a positioned parent.

04Features

  • 01Three field functions: two-octave simplex noise, interfering sine waves and noise-warped rings
  • 02Glyph atlas: each ramp step is pre-rendered once, frames are drawImage blits
  • 03Any charset (Unicode-aware), e.g. block shades or binary digits
  • 04Hover glow and expanding click/tap ripples, tracked on the window so overlaid content stays clickable
  • 05~30fps pacing; the loop idles at speed 0 once interactions settle
  • 06DPR-aware canvas (capped at 2), ResizeObserver, pauses offscreen and in hidden tabs, theme-aware ink
motion · continuousinput · pointerinput · clickinput · viewport

05Accessibility

  • The canvas is aria-hidden and ignores pointer events; layered content stays fully interactive.
  • prefers-reduced-motion renders a single still frame and disables hover and ripple effects.
  • Hover brightening only follows mouse and pen pointers, so touch scrolling never lights the field.
  • Very light accents are deepened automatically on light themes so dense characters keep their contrast.

06Limitations

  • Canvas text is decorative: the characters are not selectable or readable by assistive tech.