| Crates.io | simple_colour |
| lib.rs | simple_colour |
| version | 1.0.4 |
| created_at | 2026-01-22 15:52:26.712404+00 |
| updated_at | 2026-01-23 15:16:00.809518+00 |
| description | A crate that allows programmers to change the style or colour of their strings |
| homepage | |
| repository | https://github.com/NikolasNikshiqi/simple_colour |
| max_upload_size | |
| id | 2062011 |
| size | 23,812 |
simple_colour is a lightweight, zero-dependency Rust library that provides a convenient Trait-based approach to styling terminal output.
Easy Integration:: Just import the Colour trait and use methods directly on &str or String.Chainable: Combine styles, foregrounds, and backgrounds easily.TrueColour Support: Access the full 24-bit colour range using RGB or 8-bit (256-colour) palettes.Specialty Effects: Includes a built-in rainbow() method for easy text effects.Add this to your Cargo.toml:
[dependencies]
simple_colour = "1.0.4"
use simple_colour::Colour;
fn main() {
// Basic Styling
println!("{}", "Hello World Italic".italic());
println!("{}", "Hello World Red".red());
// Combining styles
println!("{}", "Hello World Bold Red".red().bold());
// Bright Colours
println!("{}", "Hello World Bright Blue".bright_blue());
// 8-bit Truecolour (0-255)
println!("{}", "Yellow-Green".truecolour(192));
println!("{}", "Yellow-Green BG".bg_truecolour(192));
// 24-bit RGB Truecolour
println!("{}", "Cyan Text".truecolour_rgb(0, 170, 170));
println!("{}", "Cyan Background".bg_truecolour_rgb(0, 170, 170));
// Rainbow Effect
println!("{}", "Full spectrum rainbow text!".rainbow());
// Reset
let str = "Hello world".red().bold();
let str = str.reset();
println!("{}",str);
}
| Method | Description |
|---|---|
.bold() |
Makes text bold |
.italic() |
Makes text italic |
.rainbow() |
Cycles through colours for each character |
.black(), .red(), .green(), .yellow(), .blue(), .magenta(), .cyan(), .white().bright_black(), .bright_red(), .bright_green(), .bright_yellow(), .bright_blue(), .bright_magenta(), .bright_cyan(), .bright_white().orange(), .indigo(), .violet().bg_black(), .bg_red(), .bg_green(), .bg_yellow(), .bg_blue(), .bg_magenta(), .bg_cyan(), .bg_white().bg_bright_black(), .bg_bright_red(), .bg_bright_green(), .bg_bright_yellow(), .bg_bright_blue(), .bg_bright_magenta(), .bg_bright_cyan(), .bg_bright_white().truecolour(u8) / .bg_truecolour(u8): Sets colour using 8-bit ANSI codes (0-255)..truecolour_rgb(r, g, b) / .bg_truecolour_rgb(r, g, b): Sets colour using 24-bit RGB values.This project is licensed under the MIT License.