Skip to main content

Crate tui_overlay

Crate tui_overlay 

Source
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.
OverlayState
Owns overlay lifecycle, animation progress, and the computed inner area.

Enums§

Anchor
9-point positioning grid for overlay placement within a parent area.
Easing
Animation curve applied to overlay slide progress.
Slide
Edge the overlay enters from during animation.