5 releases

0.1.4 Aug 31, 2024
0.1.3 May 7, 2024
0.1.2 May 6, 2024
0.1.1 Apr 30, 2024
0.1.0 Apr 24, 2024

#1084 in Command line utilities

Download history 219/week @ 2024-08-29 9/week @ 2024-09-05 14/week @ 2024-09-12 8/week @ 2024-09-19 10/week @ 2024-09-26 7/week @ 2024-10-03 2/week @ 2024-10-17 2/week @ 2024-10-24 2/week @ 2024-11-14 2/week @ 2024-11-21 18/week @ 2024-11-28 78/week @ 2024-12-05

100 downloads per month
Used in bubblers

Apache-2.0

3.5MB
3.5K SLoC

rustubble

Beautifull components for your terminal.

Rust

Motive

This project aims to provide a set of components that can be used in your terminal applications.

Components

TextInput Component

textInput

The TextInput component is a versatile and customizable input field designed for terminal-based applications using Rust. It supports Unicode, dynamic input handling, and comes with a variety of customization options to enhance user interaction.

Features

  • Unicode Support: Handles Unicode input seamlessly.
  • Dynamic Input Handling: Supports real-time input processing including pasting and deletion.
  • Customization: Allows setting up padding, placeholder, initial text, and helper text.
  • Cursor Management: Manages cursor positioning and ensures it is always placed correctly based on user interaction.

Usage

TextArea Component

textArea

A text area field, akin to an <textarea /> in HTML. Allows for input that spans multiple lines. Supports unicode, pasting, vertical scrolling when the value exceeds the width and height of the element, and many customization options.

Usage

Spinner Component

spinner

The Spinner Component provides an easy-to-use and customizable loading animation for CLI applications written in Rust, utilizing the Crossterm library to handle terminal output. This component allows for a dynamic visual display during long-running operations.

Features

  • Multiple Spinner Styles: Choose from a variety of predefined spinner styles including dots, lines, and more complex patterns.
  • Customizable Speed: Control the speed of the spinner animation.
  • Customizable Messages: Attach messages alongside the spinner to provide real-time feedback to users.
  • Easy Integration: Simple API for starting, updating, and stopping the spinner.

Usage

Customizing the Spinner

You can customize the spinner style and message at initialization. Here's how you can specify a different spinner style:

let spinner = Spinner::new("Dots2", "Loading resources...");

Available styles include Dots, Dots2, Dots3, etc. Refer to the spinner_data.rs file for a complete list of available styles and their configurations.

Spinner Styles

The spinner styles are predefined in a lazy_static block within the spinner_data.rs file. Each style is represented by a unique key and includes an array of frames and an interval timing in milliseconds.

Here’s an excerpt from the spinner styles definition:

lazy_static! {
    static ref SPINNERS: HashMap<String, SpinnerData> = {
        hashmap! {
            "Dots".into() => SpinnerData {
                frames: vec!["", "", "", "", "", "", "", "", "", ""],
                interval: 80
            },
            // Additional spinner styles...
        }
    };
}

Table Component

The Table component allows you to create a table in your terminal application using Rust. The component provides a flexible and customizable way to display data in a table format.

table

Usage

Customizing the Table

You can set the padding, the number of visible lines and the scroll offset of the table. Here's an example of how you can customize the table:

let mut table = Table::new(headers, data, 0, 3, 7);

You can set the position of the table on the view when rendering:

 let (x, y) = (5, 5);
  handle_table(&mut table, x, y);

Progress bar Component

The ProgressBar component is a versatile and customizable loading animation for CLI applications written in Rust. This component allows for a dynamic visual display during long-running operations.

progress

Usage

ViewPort Component

The ViewPort component allows you to create a viewport in your terminal application. The component provides a flexible and customizable way to display data in a String view format

viewport

Usage

StopWatch Component

A simple component for counting down.

stopwatch

Usage

Timer Component

A simple component for counting up.

timer

Usage

List Component

list

A list component, build with ratatui.

Usage

MenuList Component

menulist

A menu list component, build with ratatui.

Usage

Contribution

Contributions are welcome! If you have suggestions for improving the spinner or adding new styles, please open an issue or pull request on our GitHub repository.

License

This project is licensed under the Apache License - see the LICENSE file for details.

Dependencies

~7–16MB
~224K SLoC