install
npm i @iwascreatedtocreate/asciikit # or pnpm add / yarn add / bun add
Three entry points: @iwascreatedtocreate/asciikit (framework-free core), @iwascreatedtocreate/asciikit/react (components & hooks) and @iwascreatedtocreate/asciikit/fonts (one export per font).
<Ascii />
import { Ascii } from '@iwascreatedtocreate/asciikit/react';
import { Slant, AnsiShadow } from '@iwascreatedtocreate/asciikit/fonts';
<Ascii text="Hello" /> // Standard font built in
<Ascii text="Hello" font={Slant} size={10} />
<Ascii text="Hello" font={AnsiShadow} gradient="silver" glow />
<Ascii text="Hi" font={Slant} border={{ style: 'double', title: 'v1' }} shadow />
<Ascii text="Boot" font={AnsiShadow} animate="scramble" />
<Ascii as="h1" text="Title" label="Title" /> // semantic + accessible| prop | type | description |
|---|---|---|
| text | children | string | text to render |
| font | FontDefinition | string | imported font, raw .flf text or registered name |
| horizontalLayout | 'default' | 'full' | 'fitted' | 'smush' | 'universal-smush' | how glyphs meet |
| verticalLayout | same as above | how lines meet |
| horizontalRules / verticalRules | { equal, underscore, hierarchy, … } | toggle individual smushing rules |
| width | number | word-wrap at N columns |
| align | 'left' | 'center' | 'right' | line alignment |
| letterSpacing / wordSpacing / lineGap | number | spacing in columns / rows |
| direction | 'ltr' | 'rtl' | override font direction |
| fill | string | replace every visible char (e.g. █) |
| replace | Record<string, string> | char replacement map |
| border | boolean | BoxStyle | BoxOptions | 15 styles, title, footer, padding |
| shadow | boolean | { x, y, char } | drop shadow |
| flip / rotate / scale / invert | … | geometric transforms |
| padding | number | { x, y, top, … } | blank space around |
| transform | (art) => string | your own post-processing |
| color / gradient / gradientDirection | string | string[] | preset | CSS color or background-clip gradient |
| size / lineHeight / fontFamily / glow | … | typography |
| animate | effect | { effect, duration, loop, trigger, … } | see animation |
| as / label | ElementType / string | false | element & aria-label |
Make your own reusable component, lucide-style:
import { createAscii } from '@iwascreatedtocreate/asciikit/react';
import { Slant } from '@iwascreatedtocreate/asciikit/fonts';
export const Logo = createAscii('ACME', { font: Slant, gradient: 'mono' });
// <Logo size={8} />fonts
332 fonts, each in its own module. Import by name from the barrel (tree-shaken), by path, or load on demand.
import { Slant, Doom, Graffiti } from '@iwascreatedtocreate/asciikit/fonts'; // tree-shakable barrel
import Ghost from '@iwascreatedtocreate/asciikit/fonts/ghost'; // direct path
import { loadFont } from '@iwascreatedtocreate/asciikit/fonts/lazy'; // code-split, async
import { fontList } from '@iwascreatedtocreate/asciikit/fonts/meta'; // names & sizes, no glyph data
const font = await loadFont('ANSI Shadow'); // id or display name
// in client components
import { useFont } from '@iwascreatedtocreate/asciikit/react';
const { font, loading } = useFont('ansi-shadow');
// register for string lookup
import { registerFont, setDefaultFont } from '@iwascreatedtocreate/asciikit';
registerFont(Slant); render('hi', { font: 'slant' });
setDefaultFont(Doom);
// bring your own .flf / .tlf
import { parseFont } from '@iwascreatedtocreate/asciikit';
const mine = parseFont(await (await fetch('/my.flf')).text());layout & smushing
A full FIGfont 2 engine: full width, fitting (kerning), controlled smushing with all six horizontal rules (equal, underscore, hierarchy, opposite pair, big X, hardblank) and universal smushing — plus the five vertical rules for multi-line text. Output matches figlet.js / TAAG for 97%+ of fonts.
render('Hello', { font: Standard, horizontalLayout: 'fitted' });
render('Hello', { font: Standard, horizontalRules: { hierarchy: false } });
render('two\nlines', { font: Standard, verticalLayout: 'smush' });
render('a long sentence', { font: Standard, width: 60, align: 'center' });effects
Pure string functions — chain them with pipe(), use them in CLIs, emails, logs.
import { render, pipe, box, shadow, fill, flipHorizontal, rotate, scale,
invert, pad, trim, join, stack, overlay, toAnsi, toHTML } from '@iwascreatedtocreate/asciikit';
const art = pipe(
render('OK', { font: Slant }),
(a) => fill(a, '█'),
(a) => shadow(a, { char: '░' }),
(a) => box(a, { style: 'rounded', title: 'status', padding: 1 }),
);
console.log(toAnsi(art, { gradient: 'sunset' })); // 24-bit terminal colors
join([logo, info], { gap: 4, align: 'middle' }); // side by sideanimation
scramble typewriter reveal fall flicker glitch wave rain. Respects prefers-reduced-motion.
<Ascii text="Hi" animate="glitch" />
<Ascii text="Hi" animate={{ effect: 'scramble', duration: 2000, delay: 300,
loop: true, loopDelay: 1500, trigger: 'visible' /* | 'mount' | 'hover' */ }} />
// framework-free: compute any frame yourself
import { animationFrame } from '@iwascreatedtocreate/asciikit';
const frame = animationFrame(art, 'typewriter', 0.5);image → ascii
import { AsciiImage } from '@iwascreatedtocreate/asciikit/react';
<AsciiImage src="/me.jpg" columns={100} mode="braille" dither="atkinson" />
<AsciiImage src={file} charset="blocks" color invert contrast={1.4} />
// server / node: decode pixels however you like (sharp, canvas…)
import { pixelsToAscii } from '@iwascreatedtocreate/asciikit';
const { text } = pixelsToAscii({ data, width, height }, { columns: 80 });core api
import { render, renderLines, ascii } from '@iwascreatedtocreate/asciikit';
render(text, options) // string — FIGlet rendering
renderLines(text, options) // string[]
ascii(text, options) // render + transforms (fill, border, shadow…)
textSync(text, options) // figlet.js-compatible aliasnext.js tips
<Ascii> renders on the server, so fonts never reach the browser. When you animate, only the final string is sent to the client. For font pickers use useFont() so each font is its own chunk. Optional:
// next.config.js — faster dev builds when importing many fonts from the barrel
experimental: { optimizePackageImports: ['@iwascreatedtocreate/asciikit'] }