#2458·ratatui

A new `unstable-wrap` flag that exposes `WordWrapper`

Author: sxyaziCreated Mar 23, 2026Updated Aug 3, 2026
LabelsType: Enhancement

Problem

Paragraph uses WordWrapper to wrap text, but WordWrapper isn't exported, and there's no way to get fine-grained control over Paragraph.

For example, for file previews I want to only load the first n visible lines into the Paragraph instead of filling the whole file into it, then load skip+n lines as the user scrolls to improve preview performance, which needs a way to pre-process text with the exact same wrapping algorithm Paragraph uses.

Right now I'm copying WordWrapper downstream: https://github.com/sxyazi/yazi/blob/main/yazi-shim/src/ratatui/wrapper.rs

But that requires maintaining a separate copy and sync it whenever Ratatui changes it to keep behavior identical, which isn't ideal.

Solution

Expose WordWrapper behind an unstable-wrap gate so user-space code can use it while keeping it unstable and free to change in the future.

Alternatives

Use a standalone textwrap crate solely for previews, but I'm not sure its algorithm matches Ratatui's exactly - if it doesn't, preview wrapping would behave differently from other UI wrapping that uses Paragraph::wrap()

Are you willing to contribute an implementation?

  • I am willing to open a PR implementing this.
  • I can try to implement it, but I will need guidance.
  • I am not able to implement this right now.

Additional context

Maybe future experimental tries for https://github.com/ratatui/ratatui/issues/293 could also be put behind the unstable-wrap gate.