| Crates.io | tui-prompts |
| lib.rs | tui-prompts |
| version | 0.6.1 |
| created_at | 2023-07-11 05:45:55.94635+00 |
| updated_at | 2025-12-27 07:28:04.461734+00 |
| description | A library for building interactive prompts for ratatui. |
| homepage | |
| repository | https://github.com/joshka/tui-widgets |
| max_upload_size | |
| id | 913515 |
| size | 120,131 |
A Ratatui widget set for friendly prompts and input flows. Part of the tui-widgets suite by Joshka.
GitHub Repository · API Docs · Examples · Changelog · Contributing
cargo add ratatui tui-prompts crossterm
Pick a prompt type, keep its state, and render it inside your UI.
use ratatui::layout::{Constraint, Direction, Layout, Rect};
use ratatui::Frame;
use tui_prompts::{Prompt, TextPrompt, TextRenderStyle, TextState};
struct App<'a> {
username_state: TextState<'a>,
password_state: TextState<'a>,
invisible_state: TextState<'a>,
}
impl<'a> App<'a> {
fn draw_ui(&mut self, frame: &mut Frame) {
let (username_area, password_area, invisible_area) = split_layout(frame.area());
TextPrompt::from("Username")
.draw(frame, username_area, &mut self.username_state);
TextPrompt::from("Password")
.with_render_style(TextRenderStyle::Password)
.draw(frame, password_area, &mut self.password_state);
TextPrompt::from("Invisible")
.with_render_style(TextRenderStyle::Invisible)
.draw(frame, invisible_area, &mut self.invisible_state);
}
}
fn split_layout(area: Rect) -> (Rect, Rect, Rect) {
let rows = Layout::default()
.direction(Direction::Vertical)
.constraints([
Constraint::Length(1),
Constraint::Length(1),
Constraint::Length(1),
])
.split(area);
(rows[0], rows[1], rows[2])
}

See the text example for more details.
Text is automatically character wrapped to fit in the render area.

See the multi line example for more details.
^[b and ^[f| Key | Action |
|---|---|
| Home, Ctrl+A | Move cursor to beginning of line |
| End, Ctrl+E | Move cursor to end of line |
| Left, Ctrl+B | Move cursor one character left |
| Right, Ctrl+F | Move cursor one character right |
| Backspace (Delete on Mac), Ctrl+H | Delete character before cursor |
| Delete (Fn+Delete on Mac), Ctrl+D | Delete character at cursor |
| Ctrl+K | Delete all characters from the cursor to the end of line |
| Ctrl+U | Delete the entire line |
| Enter | Complete the prompt |
| Escape, Ctrl+C | Abort the prompt |
For the full suite of widgets, see tui-widgets.
Copyright (c) Josh McKinney
This project is licensed under either of:
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
See CONTRIBUTING.md.