- Home
- Skills
- Frontend & Web Apps
- pretext-layout
Pretext Layout
High-performance browser-based text layout and measurement for virtualization, canvas, and layout-heavy applications.
Free
Works with the AI tools you already use
pretext-layout
Example session with this skill installed
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.
- Read your context and instructions
- Compiled the pretext-layout
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.
Connects securely to your tools. The creator never sees your data.
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
Works the same in every agent - Claude, Cursor, Codex, Copilot and 20+ more.
- 1
Download the ZIP
Free skills download straight away. Paid skills unlock right after purchase.
- 2
Unzip into your skills folder
Every agent reads skills from one folder on your machine. Drop the unzipped folder in there.
- 3
Ask your agent to use it
Restart the agent if it was already running. It picks the skill up automatically - no config needed.
Skills folder by agent
Click the path to copy it. Create the folder if it does not exist yet.
Reviews
37 people have installed this skill.
Trust & safety
Security scanned
Verified clean 6 months ago
- Free to download with an account