Expand description
Composable overlay widget for Ratatui: drawers, modals, popovers, and toasts from a single configurable primitive.
§Quick start
use std::time::Duration;
use ratatui_core::layout::Constraint;
use tui_overlay::{Anchor, Easing, Overlay, OverlayState, Slide};
let overlay = Overlay::new()
.anchor(Anchor::Right)
.slide(Slide::Right)
.width(Constraint::Percentage(30));
let mut state = OverlayState::new()
.with_duration(Duration::from_millis(150))
.with_easing(Easing::EaseOut);
state.open();§Rendering
Render main content first, then the overlay (which dims and draws chrome), then body content into the exposed inner area.
ⓘ
// 1. Main UI
frame.render_widget(dashboard, area);
// 2. Overlay (backdrop + chrome)
frame.render_stateful_widget(overlay, area, &mut state);
// 3. Body content into the overlay
if let Some(inner) = state.inner_area() {
frame.render_widget(detail_panel, inner);
}Call OverlayState::tick with elapsed time each frame to drive slide animation.
For click-outside-to-dismiss, use OverlayState::overlay_rect for hit testing.
Structs§
- Backdrop
- Dimming layer behind an open overlay.
- Overlay
- Composable overlay widget for Ratatui.
- Overlay
State - Owns overlay lifecycle, animation progress, and the computed inner area.