tui-prompts 0.2.0

A library for building interactive prompts for ratatui.
Documentation

tui-prompts

Crates.io License Docs.rs
Dependency Status Codecov Discord

tui-prompts is a Rust crate that provides prompt widgets for the Ratatui crate. It allows for easy creation of interactive command-line interfaces with various types of prompts. Inspired by https://www.npmjs.com/package/prompts and various other prompt libraries.

Installation

Add the following to your Cargo.toml file:

[dependencies]
ratatui = "0.21.0"
tui-prompts = "0.1.0"

Status

Very much a work in progress

Examples

struct App<'a> {
    username: TextState<'a>,
    password: TextState<'a>,
}

impl<'a> App<'a> {
    fn draw_ui<B: Backend>(&mut self, frame: &mut Frame<B>) {
        let area = Rect::new(0, 0, frame.size().width, 1);
        TextPrompt::from("Username").draw(frame, area, &mut self.username);

        let area = Rect::new(0, 1, frame.size().width, 1);
        TextPrompt::from("Password")
            .with_render_style(TextRenderStyle::Password)
            .draw(frame, area, &mut self.password);
    }
}

Text Prompt

License

Dual-licensed under Apache 2.0 or MIT.