| Crates.io | colorex |
| lib.rs | colorex |
| version | 0.1.1 |
| created_at | 2025-02-02 10:19:39.790148+00 |
| updated_at | 2025-02-07 09:03:56.730831+00 |
| description | A simple and flexible Rust library for styling terminal output with color and text formatting. Supports RGB/HEX colors, text styles (bold, italic, underline, etc.), and background colors with a chainable API. |
| homepage | |
| repository | https://github.com/colorex-lbrary/colorex |
| max_upload_size | |
| id | 1539453 |
| size | 26,147 |
colorex is a simple and flexible Rust library that provides an easy way to style your terminal output with color and text formatting. With support for both RGB and HEX color codes, as well as text styles like bold, italic, underline, strikethrough, and more, it makes your terminal applications visually more appealing and readable.
To use colorex, add it to your Cargo.toml file:
[dependencies]
colorex = "0.1.1"
Here's how you can use colorex to add color and styles to your terminal output:
use colorex::Colorize;
fn main() {
// Basic color usage
println!("{}", "Hello, World!".color("0,255,0")); // Green text
println!("{}", "Error!".color("#FF0000")); // Red text
// Text styles
println!("{}", "Bold Text".bold()); // Bold text
println!("{}", "Italic Text".italic()); // Italic text
println!("{}", "Underlined Text".underline()); // Underlined text
println!("{}", "Strikethrough Text".strikethrough()); // Strikethrough text
println!("{}", "Dim Text".dim()); // Dim text
println!("{}", "Inverted Text".invert()); // Inverted (background) text
// Background color
println!("{}", "Background Color".bg_color("0,0,255")); // Blue background
// Combining multiple styles
println!("{}", "ALL".color("0,255,0").bold().italic().underline().strikethrough().dim().invert().bg_color("0,0,255")); // All styles
}
The following example would result in a green-colored "Hello, World!" and a red "Error!" message in the terminal.
println!("{}", "Hello, World!".color("0,255,0")); // Green text
println!("{}", "Error!".color("#FF0000")); // Red text
"r,g,b" (e.g., "255,0,0" for red)."#RRGGBB" (e.g., "#FF0000" for red).This project is licensed under the MPL-2.0 License - see the LICENSE file for details.