EveryDev.ai
Subscribe
Home
Tools

6,671+ AI tools

  • Featured
  • Gems
  • Trending
  • New
  • Rate tools
  • Compare
  • Arena
Categories
  • Agents3542
  • Coding2670
  • Infrastructure1126
  • Projects931
  • MCP913
  • Research774
  • Analytics603
  • Marketing553
  • Design537
  • Testing500
  • Data456
  • Security449
  • Communication330
  • Prompts310
  • Integration308
  • Extensions264
  • Voice236
  • DevOps204
  • Commerce192
  • Learning145
  • Web136
  • Finance44
AI Tools by Topic
  • AI Coding Assistants
  • Agent Frameworks
  • MCP Servers
  • AI Prompt Tools
  • Vibe Coding Tools
  • AI Design Tools
  • AI Database Tools
  • AI Website Builders
  • AI Testing Tools
  • LLM Evaluations
Follow Us
  • X / Twitter
  • LinkedIn
  • Reddit
  • Discord
  • Threads
  • Bluesky
  • Mastodon
  • YouTube
  • GitHub
  • Instagram
Get Started
  • Users
  • Rate Tools
  • About
  • Editorial Standards
  • Corrections & Disclosures
  • Community Guidelines
  • Advertise
  • Contact Us
  • Newsletter
  • Submit a Tool
  • Start a Discussion
  • Write A Blog
  • Share A Build
  • Terms of Service
  • Privacy Policy
Explore with AI
  • ChatGPT
  • Gemini
  • Claude
  • Grok
  • Perplexity
Agent Experience
  • llms.txt
Theme
With AI, Everyone is a Dev. EveryDev.ai ©
    1. Home
    2. Tools
    3. Pretext
    Pretext icon

    Pretext

    Web Performance
    Featured

    Pure TypeScript library for fast multiline text measurement and layout without DOM reflow.

    Visit Website

    At a Glance

    Pricing
    Open Source

    Pure TypeScript library for multiline text measurement and layout, released under the MIT License. Bundled third-party notices (Chromium/WebKit BSD-style, ICU/Unicode) are also permissive.

    Engagement

    Available On

    Windows
    macOS
    iOS
    Web
    API

    Resources

    WebsiteDocsGitHubllms.txt

    Topics

    Web PerformanceDesign ResourcesAI Development Libraries

    Alternatives

    AI ElementsThinking OrbsPele
    Developer
    Cheng LouCalifornia, United States

    Listed Nov 2026

    About Pretext

    Pretext is an open-source JavaScript/TypeScript library by chenglou for measuring and laying out multiline text without relying on DOM measurements. It computes paragraph height, line counts and individual lines, and its output can be rendered to DOM, Canvas and SVG. The latest listed release is v1.0.0.

    What It Is

    Pretext is a text measurement and layout library for web interfaces. Instead of calling DOM APIs such as getBoundingClientRect or offsetHeight, which trigger layout reflow, it implements its own measurement logic and uses the browser's font engine as ground truth. It aims to support text in many languages, including mixed scripts and emoji.

    How the Workflow Works

    A call to prepare() does the one-time work: it normalizes whitespace, segments text at break opportunities and measures the segments with canvas. layout() then calculates height and line count with pure arithmetic over the cached widths, so on resize only layout() needs to be rerun.

    For manual layout, prepareWithSegments() unlocks layoutWithLines(), layoutNextLine() and range-based APIs such as walkLineRanges(), measureLineStats() and layoutNextLineRange(). These support shrink-wrapped chat bubbles, text flowing around obstacles and per-line variable widths. A rich-inline entry point lays out mixed fonts, code spans, chips and images as one paragraph.

    Use Cases and Demos

    The documentation lists virtualization and occlusion, masonry and other JS-driven layouts, development-time checks that button labels do not overflow, and preventing layout shift. Demos cover accordions, bubbles, editorial layouts, justification comparison, rich text, a 10,000-message Markdown chat, ellipsis clamping and masonry.

    Caveats to Know

    Pretext targets white-space normal and pre-wrap, word-break normal and keep-all, and overflow-wrap: break-word. It requires Canvas 2D text measurement and Unicode property escapes, so it needs a browser or a supplied OffscreenCanvas shim elsewhere. Fonts must be loaded before preparing text, and system-ui is unsafe for accuracy on macOS.

    Pretext - 1

    Community Discussions

    Be the first to start a conversation about Pretext

    Share your experience with Pretext, ask questions, or help others learn from your insights.

    Pricing

    OPEN SOURCE

    Open Source (MIT)

    Pure TypeScript library for multiline text measurement and layout, released under the MIT License. Bundled third-party notices (Chromium/WebKit BSD-style, ICU/Unicode) are also permissive.

    • MIT License
    • Install via npm: @chenglou/pretext
    • Pure JavaScript/TypeScript text measurement & layout
    • Renders to DOM, Canvas and SVG

    Capabilities

    Key Features

    • Measure paragraph height and line count without DOM reflow
    • Manual line-by-line layout with variable widths
    • Shrink-wrap multiline text to its widest line
    • Rich inline layout with mixed fonts, chips and images
    • pre-wrap and keep-all modes plus letter-spacing option
    • Soft hyphen support
    • Multilingual text support including Southeast Asian scripts via Intl.Segmenter
    • Rendering to DOM, Canvas and SVG
    • Locale setting and cache clearing helpers
    API Available
    View Docs

    Ratings & Reviews

    No ratings yet

    Be the first to rate Pretext and help others make informed decisions.

    Rate other tools you’ve used

    Developer

    Cheng Lou

    Work: ReactJS, ReasonML, ReScript, Messenger, Midjourney

    California
    Read more about Cheng Lou
    WebsiteGitHubX / Twitter
    2 tools in directory

    Similar Tools

    AI Elements icon

    AI Elements

    A component library and custom registry built on shadcn/ui to help you build AI-native applications faster.

    Thinking Orbs icon

    Thinking Orbs

    A React component library of animated AI status indicators with no dependencies and a 3.8 KB gzipped size.

    Pele icon

    Pele

    A lightweight open source library that renders Mermaid diagrams to SVG, themed with CSS variables.

    Browse all tools

    Related Topics

    Web Performance

    AI-powered tools that optimize and enhance web application performance through intelligent asset optimization, caching strategies, and real-time monitoring with automated improvement suggestions.

    6 tools

    Design Resources

    AI-curated collections of stock photos, icons, templates, and other design assets with intelligent search, style matching, and personalized recommendations.

    70 tools

    AI Development Libraries

    Programming libraries and frameworks that provide machine learning capabilities, model integration, and AI functionality for developers.

    603 tools
    Browse all topics
    Back to all toolsSuggest an edit
    ratings
    discussions