Saltar al contenido
Skillpedia
Sitios e interfaces (frontend)260 mil · #474

pretext

Qué hace

Ayuda a crear demos creativas de navegador en las que el texto es el elemento visual principal, como párrafos que fluyen alrededor de un sprite en movimiento. Es para desarrolladores y diseñadores que quieren efectos web poco habituales y llamativos.

Cuándo usarla

  • ✓Cuando quieres que un texto fluya alrededor de una forma o de un elemento animado en movimiento.
  • ✓Cuando quieres un juego o un efecto de estilo ASCII construido con palabras reales.
  • ✓Cuando quieres una tipografía cinética que rompa el texto en partículas.

Link de la skill

https://github.com/NousResearch/hermes-agent/blob/main/optional-skills/creative/pretext/SKILL.md

Cópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.

Cómo usar

La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.

Mensaje listo para pegar

Usa esta skill para ayudarme: https://github.com/NousResearch/hermes-agent/blob/main/optional-skills/creative/pretext/SKILL.md Lee el archivo SKILL.md de ese link y sigue sus instrucciones en mi tarea.
¿Quieres que tu IA encuentre skills como esta por sí sola?Instala el MCP gratis de Skillpedia: una línea, y busca entre 15.000+ skills antes de cada tarea.Instalar en 1 minuto →

Ejemplo de qué pedirle a la IA

“Haz una demo de navegador en la que un párrafo se reajuste alrededor de una pelota que rebota por la página.”

5 skills nuevas por semana. 1 minuto de lectura.

Cómo funciona

El agente usa la librería pretext para medir y disponer el texto sin el paso habitual de maquetación del navegador, de modo que las posiciones se actualizan rápido en cada fotograma. Después construye el efecto visual sobre esa disposición.

Contenido técnico (SKILL.md original)

Texto original del autor, en inglés, directo de GitHub.

Pretext Creative Demos

Overview

@chenglou/pretext is a 15KB zero-dependency TypeScript library by Cheng Lou (React core, ReasonML, Midjourney) for DOM-free multiline text measurement and layout. It does one thing: given (text, font, width), return the line breaks, per-line widths, per-grapheme positions, and total height — all via canvas measurement, no reflow.

That sounds like plumbing. It is not. Because it is fast and geometric, it is a creative primitive: you can reflow paragraphs around a moving sprite at 60fps, build games whose level geometry is made of real words, drive ASCII logos through prose, shatter text into particles with exact per-grapheme starting positions, or pack shrink-wrapped multiline UI without any getBoundingClientRect thrash.

This skill exists so Hermes can make cool demos with it — the kind people post to X. See pretext.cool and chenglou.me/pretext for the community demo corpus.

When to Use

Use when the user asks for:

  • A "pretext demo" / "cool pretext thing" / "text-as-X"
  • Text flowing around a moving shape (hero sections, editorial layouts, animated long-form pages)
  • ASCII-art effects using real words or prose, not monospace rasters
  • Games where the playfield / obstacles / bricks are made of text (Tetris-from-letters, Breakout-of-prose)
  • Kinetic typography with per-glyph physics (shatter, scatter, flock, flow)
  • Typographic generative art, especially with non-Latin scripts or mixed scripts
  • Multiline "shrink-wrap" UI (smallest container width that still fits the text)
  • Anything that would require knowing line breaks before rendering

Don't use for:

  • Static SVG/HTML pages where CSS already solves layout — just use CSS
  • Rich text editors, general inline formatting engines (pretext is intentionally narrow)
  • Image → text (use ascii-art / ascii-video skills)
  • Pure canvas generative art with no text role — use p5js

Creative Standard

This is visual art rendered in a browser. Pretext returns numbers; you draw the thing.

  • Don't ship a "hello world" demo. The hello-orb-flow.html template is the starting point. Every delivered demo must add intentional color, motion, composition, and one visual detail the user didn't ask for but will appreciate.
  • Dark backgrounds, warm cores, considered palette. Classic amber-on-black (CRT / terminal) works, but so do cold-white-on-charcoal (editorial) and desaturated pastels (risograph). Pick one and commit.
  • Proportional fonts are the point. Pretext's whole vibe is "not monospaced" — lean into it. Use Iowan Old Style, Inter, JetBrains Mono, Helvetica Neue, or a variable font. Never default sans.
  • Real source/text, not lorem ipsum. The corpus should mean something. Short manifestos, poetry, real source code, a found text, the library's own README — never lorem ipsum.
  • First-paint excellence. No loading states, no blank frames. The demo must look shippable the instant it opens.

Stack

Single self-contained HTML file per demo. No build step.

Layer Tool Purpose
Core @chenglou/pretext via esm.sh CDN Text measurement + line layout
Render HTML5 Canvas 2D Glyph rendering, per-frame composition
Segmentation Intl.Segmenter (built-in) Grapheme splitting for emoji / CJK / combining marks
Interaction Raw DOM events Mouse / touch / wheel — no framework
<script type="module">
import {
  prepare, layout,                   // use-case 1: simple height
  prepareWithSegments, layoutWithLines,  // use-case 2a: fixed-width lines
  layoutNextLineRange, materializeLineRange, // use-case 2b: streaming / variable width
  measureLineStats, walkLineRanges,  // stats without string allocation
} from "https://esm.sh/@chenglou/pretext@0.0.6";
</script>

Pin the version. @0.0.6 at time of writing — check npm for the latest if demo behavior is off.

The Two Use Cases

Almost everything reduces to one of these two shapes. Learn both.

Use-case 1 — measure, then render with CSS/DOM

const prepared = prepare(text, "16px Inter");
const { height, lineCount } = layout(prepared, 320, 20);

You still let the browser draw the text. Pretext just tells you how tall the box will be at a given width, without a DOM read. Use for:

  • Virtualized lists where rows contain wrapping text
  • Masonry with precise card he
Preguntas frecuentes

¿Qué es la librería pretext?

Una pequeña librería de TypeScript que mide y dispone texto de varias líneas sin tocar la maquetación de la página.

¿Es para sitios web de producción?

La skill está pensada para demos creativas, del tipo que la gente comparte en línea, más que para la maquetación cotidiana de páginas.

¿Cuánto ocupa la librería?

La skill la describe como unos 15 KB sin dependencias.

Detalles

Descripción original del autor

Build creative browser demos with DOM-free text layout.

repo: NousResearch/hermes-agent

Popularidad

Estrellas en GitHub
260 mil
Posición en el ranking
#474
Licencia
MIT
Actualizada
2/11/2026

¿Te sirve esta skill?

0

Entra para votar.

Comentarios

  • …

Más skills de este repositorio

Skills parecidas