mirror of
https://github.com/ratatui/ratatui.git
synced 2025-09-27 13:01:13 +00:00

Demonstrates how to manage the cursor and input focus with a simple form. Uses an enum to track the current input field and passes the input events to the active field. This is similar to the json tutorial on the website, but a bit simpler
Input Form example
This example demonstrates how to handle input across several form fields (2 strings and an number). It uses an enum to track the focused field, and sends keyboard events to one which is current.
Run this example with:
cargo run -p input-form
This example does not handle things like cursor movement within the line (just keys and backspace). Most apps would benefit from using the following crates for text input rather than directly using strings:
Some more ideas for handling focus can be found in:
focusable
(see also Ratatui forum post)rat-focus
- A useful
Bevy
discssion about focus more generally.