To render complex widgets (like a scrollable Paragraph) inside a Popup, the inner widget must implement the KnownSize trait. You can wrap any standard Ratatui widget with KnownSizeWrapper by providing its explicit width and height.
use ratatui::prelude::*;
use ratatui::text::{Span, Text};
use ratatui::widgets::Paragraph;
use tui_popup::{KnownSizeWrapper, Popup};
fn render_scrollable_popup(frame: &mut Frame, scroll: u16) {
let lines: Text = (0..10).map(|i| Span::raw(format!("Line {}", i))).collect();
let paragraph = Paragraph::new(lines).scroll((scroll, 0));
let sized_paragraph = KnownSizeWrapper {
inner: paragraph,
width: 21,
height: 5,
};
let popup = Popup::new(sized_paragraph)
.title("scroll: ↑/↓ quit: Esc")
.style(Style::new().white().on_blue());
frame.render_widget(popup, frame.area());
}