AsciiSweep (Solid)

AsciiSweep is a Solid.js component that swaps between two live HTML panels with a band of glowing ASCII characters sweeping across the exact text lines. The panels stay interactive, and the effect runs on a WebGL2 canvas with an optional imperative API.

component · no preview
This item cannot be built as published, so there is no live preview: build: ✗ Build failed in 212ms
See how it was built

Installation

pnpm dlx shadcn@latest add @canvas-ui/ascii-sweep-solid

Requires @canvas-ui in the registries of your components.json (shadcn adds official directory namespaces automatically).

Usage

usage.tsx
import { AsciiSweep } from "@/components/canvasui/AsciiSweep";export default function Demo() {  return (    <div style={{ width: "100%", height: "320px" }}>      <AsciiSweep index={0} alternate={<div style={{ padding: "24px" }}>Second panel</div>}>        <div style={{ padding: "24px" }}>First panel</div>      </AsciiSweep>    </div>  );}
  • Switching between two views or states (for example a before/after pair, a login/signup toggle, or two dashboard tabs) with a retro CRT or terminal-style transition.
  • Adding a hacker, cyberpunk, or glitch-art transition to a hero, landing page, or portfolio section while keeping the HTML selectable and interactive.
  • Showing a loading-to-content or theme-change moment where the page should feel like it is being scanned or rewritten by text.
  • Avoid it for simple fades or content that must stay static, and for environments that cannot tolerate WebGL or motion.

Examples

Toggle between two panels with a signal

Drive the sweep by changing the index prop. The component detects the change and sweeps to the matching panel. Set directional to false if the reverse sweep should not flip direction.

toggle-between-two-panels-with-a-signal.tsx
import { createSignal } from "solid-js";import { AsciiSweep } from "@/components/canvasui/AsciiSweep";export default function Toggle() {  const [page, setPage] = createSignal(0);  return (    <div style={{ width: "100%", height: "360px" }}>      <button onClick={() => setPage(page() === 0 ? 1 : 0)}>Switch</button>      <AsciiSweep        index={page()}        duration={1.6}        alternate={<section style={{ padding: "32px" }}><h2>Sign up</h2></section>}      >        <section style={{ padding: "32px" }}><h2>Log in</h2></section>      </AsciiSweep>    </div>  );}

Diagonal sweep with binary charset

Use angle to set the sweep direction in degrees and charset to switch the glyph ramp. Pass a custom color and tint for a branded look.

diagonal-sweep-with-binary-charset.tsx
import { AsciiSweep } from "@/components/canvasui/AsciiSweep";export default function Diagonal() {  return (    <div style={{ width: "100%", height: "420px" }}>      <AsciiSweep        angle={45}        charset="binary"        color="#38bdf8"        tint={0.9}        glow={1.5}        alternate={<article style={{ padding: "40px" }}><p>Dataset B</p></article>}      >        <article style={{ padding: "40px" }}><p>Dataset A</p></article>      </AsciiSweep>    </div>  );}

Manual progress scrubbing with custom glyphs

Set progress between 0 and 1 to drive the sweep manually, for example from a scroll position. Custom glyphs take packed 5x5 bitmaps ordered dark to bright.

manual-progress-scrubbing-with-custom-glyphs.tsx
import { createSignal } from "solid-js";import { AsciiSweep } from "@/components/canvasui/AsciiSweep";export default function Scrub() {  const [p, setP] = createSignal(0);  return (    <div style={{ width: "100%", height: "300px" }}>      <input        type="range"        min="0"        max="1"        step="0.01"        value={p()}        onInput={(e) => setP(Number(e.currentTarget.value))}      />      <AsciiSweep        progress={p()}        glyphs={[0, 128, 131200, 14336, 459200, 469440, 4357252, 18157905, 11512810, 15724526]}        alternate={<div style={{ padding: "24px" }}>Revealed</div>}      >        <div style={{ padding: "24px" }}>Original</div>      </AsciiSweep>    </div>  );}

Tracking sweep lifecycle callbacks

onSweepStart and onSweepEnd receive the destination slot index. Use them to sync analytics or other UI state with the animation.

tracking-sweep-lifecycle-callbacks.tsx
import { createSignal } from "solid-js";import { AsciiSweep } from "@/components/canvasui/AsciiSweep";export default function Lifecycle() {  const [index, setIndex] = createSignal(0);  const [busy, setBusy] = createSignal(false);  return (    <div style={{ width: "100%", height: "280px" }}>      <button disabled={busy()} onClick={() => setIndex(index() === 0 ? 1 : 0)}>Next</button>      <AsciiSweep        index={index()}        onSweepStart={(to: number) => setBusy(true)}        onSweepEnd={(to: number) => setBusy(false)}        alternate={<div style={{ padding: "24px" }}>Step 2</div>}      >        <div style={{ padding: "24px" }}>Step 1</div>      </AsciiSweep>    </div>  );}

API reference

PropTypeDefaultDescription
childrenJSX.Element—The first panel, shown when index is 0 or omitted.
alternateJSX.Element—The second panel, swapped in when index is 1.
indexnumber0Which panel to show. Values 1 and above show the alternate panel. Changing it sweeps to that panel.
directionalbooleantrueFlips the sweep 180 degrees when sweeping back to the first panel.
classstring—Class name applied to the wrapper div.
styleJSX.CSSProperties—Inline styles merged onto the wrapper div, which is position relative.
anglenumber0Sweep direction in degrees. 0 sweeps left to right, 90 sweeps bottom to top.
durationnumber2Seconds the sweep takes from one panel to the other.
bandnumber0.28Width of the ascii band as a fraction of the travel (0 to 1).
softnessnumber0.45Feather of the band edges as a fraction of the band (0 to 1).
turbulencenumber0.5How ragged the sweep edge is. Higher tears the boundary apart row by row.
trailnumber0.75Length of the glowing trail behind the band, as a fraction of the band.
progressnumber-1Drives the sweep manually from 0 to 1. Set to -1 to let the component animate itself.
scalenumber2Size of one glyph pixel in CSS pixels. Characters are 5x5 glyph pixels.
spacingnumber1Empty glyph pixels around each character (0 to 3).
charsetAsciiSweepCharset ("ascii" | "blocks" | "binary")"ascii"Built-in character ramp: real ascii glyphs, shade blocks, or binary digits.
glyphsnumber[][]Custom ramp of packed 5x5 bitmaps (dark to bright). Overrides charset when it has more than one entry.
colorstring"#4ade80"Color of the sweeping characters, as any CSS color.
tintnumber0.75How strongly the ink color replaces the content color (0 to 1).
glownumber2Soft phosphor glow around the characters (0 to 1).
aberrationnumber5Chromatic aberration across the band, in CSS pixels.
flickernumber0.35How much characters flicker on and off as the band passes (0 to 1).
densitynumber0.9Share of cells inside the band that light up (0 to 1).
displacenumber14Horizontal tearing of content rows inside the band, in CSS pixels.
contrastnumber1.2Contrast applied to character density before picking a glyph.
brightnessnumber0Density offset applied before picking a glyph (-1 to 1).
invertnumber0Invert character density inside the band (0 to 1).
thresholdnumber0.1Contrast against the background above which a pixel counts as content and grows characters.
fadenumber0.75How far the content dims underneath the band (0 to 1).
blendAsciiSweepBlend ("auto" | "add" | "over")"auto"How characters composite over the content. auto adds on dark pages and paints over on light ones.
backgroundstring"auto"Color of the page behind the content, or auto to read it from the DOM.
onSweepStart(to: number) => void—Called when a sweep starts, with the destination slot.
onSweepEnd(to: number) => void—Called once the sweep has fully settled on its destination panel.

Accessibility

  • The WebGL output canvas is marked aria-hidden="true" and has pointer-events disabled, so assistive tech and pointer input reach only the HTML panels.
  • The panel that is not currently shown receives aria-hidden="true" and inert, so it is removed from the tab order and the accessibility tree during and after a sweep.
  • Under prefers-reduced-motion: reduce the sweep completes instantly, and the fade-out is skipped.
  • Where html-in-canvas is unsupported, the component falls back to a DOM-based snapshot. The live panels remain the interactive surface.
  • Panel content stays in normal DOM, so text remains selectable and screen-reader readable. Consumers should still ensure the panels themselves carry meaningful headings and labels.
  • Avoid relying on the sweep alone to convey state. Pair it with a visible label or heading that changes with index.

Docs written by anthropic:claude-haiku-5-5 from the registry source.

Use with Coding Agent

Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.

prompt.md
Use the "AsciiSweep (Solid)" component (canvas-ui/ascii-sweep-solid) from its shadcn registry.1. Install it with: npx shadcn@latest add @canvas-ui/ascii-sweep-solid2. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: children, alternate, index, directional, class, style, angle, duration, band, softness, turbulence, trail, progress, scale, spacing, charset, glyphs, color, tint, glow, aberration, flicker, density, displace, contrast, brightness, invert, threshold, fade, blend, background, onSweepStart, onSweepEnd.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { AsciiSweep } from "@/components/canvasui/AsciiSweep";export default function Demo() {  return (    <div style={{ width: "100%", height: "320px" }}>      <AsciiSweep index={0} alternate={<div style={{ padding: "24px" }}>Second panel</div>}>        <div style={{ padding: "24px" }}>First panel</div>      </AsciiSweep>    </div>  );}```

Files & dependencies

  • components/canvasui/AsciiSweep.tsx→ components/canvasui/AsciiSweep.tsx
dependenciessolid-js@^1.9.0

Looks similar, elsewhere

There is no screenshot of this item to compare yet.