ratatui-flip-panel
A Ratatui widget for a two-faced panel that flips between front and back content with a card-flip animation ✨
Examples
Each example is self-contained — copy one whole file into your own app to bootstrap. Recording tapes for the GIFs above are committed under tapes/; regenerate with vhs tapes/<name>.tape.
Features
- Pack two related views into the same panel — a front face and a back face
- Smooth horizontal-squish animation approximates a 3-D card flip in plain ASCII
- Idiomatic
StatefulWidgetAPI — animation state lives in your app, not the widget - Builder methods for
min_width(edge-on threshold) andedge_style - Drop-in callbacks for the front and back render — close over any app state
Installation
cargo add ratatui ratatui-flip-panel
Usage
Construct a FlipState on your app struct (persists across frames), call flip() when the user requests a side change, and render a FlipPanel widget with two render callbacks each frame.
use Duration;
use ;
use ;
Tips
-
Two faces only. This widget is for exactly two related views of the same data. If you have three or more, use tabs (
tui-tabs,ratatui-comfy-tabs) — multi-page flips dilute the metaphor. -
Input handling is the host's job. The widget is render-only. Your app decides which key (or button, or gesture) calls
state.flip(). The example bindsfbecause it's mnemonic and short, but it's purely a convention — bind whatever fits your app. -
Works in event-driven loops. No 30 Hz busy-loop required. Use
state.next_tick_in()as yourevent::polltimeout: the call returnsSome(~33ms)while flipping andNoneotherwise, so the host wakes either on real input or when the widget needs its next animation frame. Seeexamples/basic.rs:let timeout = state.next_tick_in.unwrap_or; if poll? // redraw + state.tick() happens via render_stateful_widget -
Production use. Used in Vortix for the Security Guard panel (front: live verdict, back: per-connection audit trail).
Contributing
See the contribution guidelines.
License
Licensed under either Apache License Version 2.0 or The MIT License at your option.
Copyright © 2026, Harry KP