Pretext Layout
by Roy Yuen
High-performance browser-based text layout and measurement for virtualization, canvas, and layout-heavy applications.
Free
Works with the AI tools you already use
See it in action
You say
Measure the 200px width layout for "Hello World" using 24px line-height, then provide the per-line ranges and performance stats after ensuring fonts are loaded.
Your agent does
Prepared handle cached for "Hello World". Height: 48px at 200px width. Line 1: "Hello " (0-6) Line 2: "World" (6-11) Performance: <0.1ms layout time. Verified against document.fonts.ready status.
About this skill
Efficient Text Measurement & Layout
The Pretext Layout skill enables AI agents to integrate and debug high-performance multiline text measurement using the @chenglou/pretext library. It solves the common frontend performance bottleneck of "layout thrashing" by replacing slow DOM-based height probes with a fast, browser-native API approach.
What it does
This skill provides developers with a structured methodology for measuring text width and height without repeated DOM reflows. It supports high-level block height calculation for virtualization and low-level line-by-line geometry for custom Canvas or SVG rendering workflows. It handles complex edge cases including web fonts, emoji, and bidirectional text.
Supported Workflows
- Virtualization: Pre-measure list item heights for smooth scroll anchoring.
- Custom Rendering: Extract per-line ranges for manual drawing in Canvas or SVG.
- Responsive Design: Rapidly recalculate layouts during window resize events on the hot path.
- Debugging: Verify layout accuracy against real-world CSS styles and font loading states.
Why use this skill?
While a general AI can write basic JavaScript, this skill understands the specific lifecycle of the Pretext library—such as partitioning the expensive "prepare" phase from the lightweight "layout" phase. It ensures your agent correctly manages browser-only runtime constraints, font loading promises, and locale-specific white-space behaviors to prevent layout shifts and flickering.
How to install
Drop the file into your AI Agent. Works with Claude, Cursor, ChatGPT, and 20+ more.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill passes our trust checks below.
Security scanned
Passed our 8-point scan before listing
15 installs
Downloaded by developers to date
Free forever
No account required to browse
Trust & safety
Security scanned
Verified clean 4 months ago
- Free to download with an account
Creator
1124+ total installs · 111 skills on Agensi
Frequently Asked Questions
Popular in Web & App UI Design

Award Winning Design: Turn Claude Into a World Class Designer
v2 of Design Philosophy — a senior-designer brain for your agent. Industry-specific, award-caliber UI plus six pro UX reasoning modules. Same prompt, radically better design.

Cinematic Landing Page Builder
Turn any business URL into a high-end animated landing page with 4K AI assets and GSAP animations via Cloudflare.

frontend-motion-wizard
Advanced responsive layout and interactive micro-interaction engine for React, Tailwind CSS, and Framer Motion. Automatically injects fluid element states, mobile-first touch behaviors, adaptive viewports, and non-destructive layout transitions into static codebases

cinematic-4k-landing-page
Turn any business URL into a high-converting, agency-grade landing page with AI-generated 4K cinematic visuals, GSAP scroll animations, and one-command Cloudflare Pages deployment.