Build a form
Recipe for TextInput fields with Tab focus.
Build a form
Problem: collect a few text values with visible focus and keyboard-only operation.
Steps:
- Own one
TextInputper field plus afocus: usizein view state. - Render each field from its input:
self.name.clone().into_element(). Empty inputs render their placeholder dimmed. - In
handle_key, advance focus onTaband forward everything else to the focused input (see Handle keys and move focus). - Read
.contentfrom each input when the user confirms; clear or keep the values by mutating your own state — the inputs are plain structs.
Check: type in field one, press Tab, type in field two. Both values
persist and the cursor highlight follows focus. The runnable settings_log_viewer
example demonstrates exactly this form next to a live log view:
cargo run -p veloce-tui --example settings_log_viewer