Skip to content

shadcn.io is an independent project built on shadcn/ui

Pro

ASCII Background for Solid

A drifting field of light drawn in ASCII characters by brightness. For Solid with Ark UI, when a developer page wants a terminal texture.

On this page10 sections
UI library: Ark UI

A drifting field of light drawn in characters: each cell reads the field once and shows the character whose ink matches it, from a space where the field is dim to @ where it's bright. It's a GLSL scene on WebGL2 with no dependency; the characters are drawn once into a texture and sit on whole pixels, so they stay sharp at any pixel ratio. They take your theme's foreground color by default, the field empties behind the middle of the box, and the pointer brightens the characters near it.

Use it behind a developer-tool hero, a CLI or docs landing page, or a card that should look like terminal output. For characters that fall instead of shading a field, use Matrix; for the same kind of field in 1-bit pixels, Dither; for print dots that swell and shrink, Halftone. With reduced motion it holds one still frame.

Playground
ASCII Background, still
Customize

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Usage

import { Ascii } from "@/components/ui/ascii";
<Ascii class="flex min-h-[32rem] flex-col items-center justify-center gap-4">
  <h1 class="text-5xl font-semibold">Ship from the terminal</h1>
  <p class="text-foreground/80">One command builds, tests and deploys.</p>
</Ascii>

Ascii is a container: whatever you put inside sits on top of the characters, in normal flow. It fills its own box, so give it a height or content. For a backdrop behind the whole page, render it empty with className="fixed inset-0 -z-10".

Presets

Fieldthe default lookTry it
<Ascii />
BinaryTry it
<Ascii
  colors={["#0b6b3a", "#2fe38a", "#d9ffe9"]}
  contrast={1.4}
  glyphs=" 01"
  size={12}
/>
Blocksthe default lookTry it
<Ascii
  detail={0.2}
  glyphs=" ░▒▓█"
  scale={0.7}
  size={18}
  variant="clouds"
/>
Dotsthe default lookTry it
<Ascii angle={0} glyphs=" ·•●" size={12} variant="rings" />
EmberTry it
<Ascii
  colors={["#8a2a0a", "#ff6a1f", "#ffd27a"]}
  contrast={1.3}
  detail={0.6}
  scale={1.1}
  variant="clouds"
/>
OceanTry it
<Ascii
  angle={0}
  clearing={0.3}
  colors={["#3b82f6", "#22d3ee", "#e6fbff"]}
  contrast={1.3}
  glyphs=" .-~=≈"
  intensity={1.3}
  scale={0.8}
  size={16}
  speed={0.7}
/>
QuietTry it
<Ascii
  clearing={0}
  color="var(--muted-foreground)"
  contrast={0.7}
  intensity={0.6}
  size={10}
/>
Slashesthe default lookTry it
<Ascii angle={45} detail={0.8} glyphs=" ./|\X" size={16} />

Each preset is a set of props, so copy one and keep tuning. Field is the default. Binary shades with zeros and ones in three greens, Blocks with the shade characters ░▒▓█ at 18 px, and Dots draws rings in middle dots and bullets, close to a halftone. Ocean rolls tildes and equals signs straight across in blue. Quiet is 10 px characters in the muted color with no clearing, for a texture behind a whole section.

Examples

Hero

The default look behind a centered headline. clearing empties a block in the middle of the box, at most 800 by 380 px, so the copy sits on bare surface and the field comes back gradually around it.

Preview width

Ocean

glyphs=" .-~=≈" draws the field in dashes, tildes and equals signs, angle={0} rolls the waves straight down the box, and colors runs from blue for the faint characters to foam for the heavy ones, on a fixed dark surface.

Preview width

In a card

variant="rings" with glyphs=" ·•●" and size={12} draws ripples in dots. clearing={0} keeps the field even across the card, so the copy gets a translucent panel of its own.

Preview width

Customization

color is any CSS color and defaults to var(--foreground), so the characters follow your theme. colors replaces it with a gradient from the faintest characters to the heaviest, mixed in OKLab. glyphs is the ramp itself: list your characters from the least ink to the most, and start with a space to leave the dim parts empty. They're drawn in the system's monospace font.

The surface is the root's own background, bg-background by default. On a light surface a pale color is drawn as a darker ink, so a gradient made for a dark page still shows. fade masks an edge, opacity turns the whole effect down, and grain adds film grain.

<Ascii
  class="min-h-[32rem]"
  colors={["var(--muted-foreground)", "var(--primary)"]}
  fade="bottom"
  glyphs=" .:+#"
  size={12}
/>

Performance

It's one WebGL2 canvas and one fragment shader: four samples of simplex noise for the default field, taken at the middle of each pixel's cell, and two reads of the glyph texture. The texture is one row of 64 px glyphs, drawn once when the scene starts. It draws only while it's on screen and the tab is visible, shares one frame loop with every other background on the page, and lowers its own resolution if frames run long. quality sets the render scale yourself, and paused holds the frame.

Accessibility

The characters are pixels on a canvas, not text: they're hidden from assistive tech, can't be selected and let every click through to your content. With reduced motion it draws one still frame and ignores the pointer. Nothing flashes: a character dissolves into the next one as the field drifts.

Characters behind text are clutter more than a contrast problem, which is what clearing is for. Inside the cleared block of the default look, the strongest character measured 7.4:1 under dark text on white and 5.7:1 under light text on near-black. Outside it the heaviest characters are close to the foreground color, so keep copy inside the block, or give it a panel of its own.

FAQ

How do I change the colors?

color sets one CSS color for every character, and its opacity follows the brightness of the field. For a gradient, pass two to eight colors to colors, from the faintest characters to the heaviest; it replaces color. Hex, oklch() and theme variables such as var(--primary) all work, and a variable follows your theme when it changes.

Does it work on a light page?

Yes, with no prop to set. The default color is the theme's foreground, so the characters are dark print on a light page and light on a dark one. With your own colors, the scene reads the surface behind it and draws a pale color as a darker ink on a light one.

Can I use my own characters?

Yes: glyphs takes up to 64 characters, in order from the least ink to the most. A space first leaves the dim parts of the field empty. Unicode works as long as the system's monospace font has the glyph, so " ░▒▓█", " ·•●" and " 01" are all fine. Avoid a ramp made mostly of dashes: a run of them reads as a ruled line.

Is it real text I can select or copy?

No. The characters are drawn once into a texture and placed by the shader, one a cell, so nothing is in the DOM and nothing reaches a screen reader or the clipboard. That's also why thousands of them cost almost nothing to animate.

How do I put it behind the whole page?

Render it empty with className="fixed inset-0 -z-10". It still follows the pointer there, since it listens on the window. The clearing stays a block in the middle of the viewport; set clearing={0} for an even field, and lower intensity if text scrolls over it.

Will it slow my page down?

It's a light shader: four noise samples and two reads of the glyph texture a pixel, on the GPU. Nothing runs while it's off screen or the tab is hidden. If a device can't keep up, it renders fewer pixels by itself, and the cells stay whole pixels at the lower resolution.

Does it work with Next.js and server components?

Yes. Import it into a server component and it renders its box and your content on the server; the canvas starts in the browser, and the characters come on one by one over about a second. It needs WebGL2, which every current browser has. Without it the box keeps its background, or the fallback you pass.

What happens with reduced motion?

It draws one still frame of the field and stops, and the pointer no longer brightens anything. The frame is the same one every time, so the page looks the same on each visit.

API Reference

Ascii

data-slot="ascii"

PropType
angle?number

The direction the waves roll in, in degrees: 0 stacks them from top to bottom. It turns the other variants' fine structure too.

Default
-24
clearing?number

How much the field empties behind the middle of the box, where copy sits, from 0 (even everywhere) to 1.

Default
0.6
color?string

The color of the characters, any CSS color. The default follows your theme. On a light surface a pale color is drawn as a darker ink.

Default
"var(--foreground)"
colors?string[]

An optional gradient, two to eight CSS colors from the faintest characters to the heaviest. When it's set it replaces color.

Default
[]
contrast?number

How far apart the empty parts and the dense parts of the field are: 0 is an even grey of mid-weight characters, 2 is islands of heavy ones in bare surface.

Default
1
detail?number

How much fine structure the field has on top of its large forms, from 0 to 1.

Default
0.5
fade?"none" | "radial" | "top" | "bottom" | "left" | "right"

Which edges fade out to the surface: radial keeps the middle, the others name the side that fades.

Type
"none" | "radial" | "top" | "bottom" | "left" | "right"
Default
"none"
fallback?string

What shows until the first frame and in browsers without WebGL2: a CSS background value that looks like the scene.

glyphs?string

The characters, from the one with the least ink to the one with the most, up to 64. Start with a space to leave the dim parts empty. Ark default: .:;+*x%#@.

Default
GLYPHS
grain?number

Film grain over the scene, from 0 to 1.

Default
0
intensity?number

How strongly the characters show.

Default
1
interactive?boolean

Whether the scene follows the pointer and answers a press. Touch never moves it, so scrolling a page on a phone isn't disturbed.

Default
true
opacity?number

How strongly the scene shows over the surface, from 0 to 1.

Default
1
paused?boolean

Holds the current frame.

Default
false
quality?number

Render scale, from 0.25 to 1, of the screen's pixels (capped at 2×). Lower is cheaper and softer.

Default
1
scale?number

The size of the field's forms: higher packs more of them into the box.

Default
1
seed?number

Another layout of the same field, from 0 to 20.

Default
0
size?number

The height of a character's cell in pixels, from 8 to 32. A cell is a little over half as wide.

Default
14
speed?number

Animation speed: 1 is normal, 0 holds the frame.

Default
1
time?number

A fixed moment, in seconds: draws it and doesn't animate.

variant?"clouds" | "waves" | "rings"

The shape of the field: waves is bands that roll across and break up, clouds is drifting noise, rings is ripples that open from the middle.

Type
"clouds" | "waves" | "rings"
Default
"waves"