Crossterm Style | cross-platform styling.

Lines of Code Latest Version MIT docs Join us on Discord

This crate allows you to style the terminal cross-platform. It supports all UNIX and windows terminals down to windows 7 (not all terminals are tested see Tested Terminals for more info)

This crate is a sub-crate of crossterm to style the terminal, and can be use individually.

Other sub-crates are: - Crossterm Input - Crossterm Terminal - Crossterm Screen - Crossterm Cursor

When you want to use other modules as well you might want to use crossterm with feature flags.

Table of contents:

Getting Started

This documentation is only for crossterm_style version 0.3 if you have an older version I suggest you check the Upgrade Manual. Also, check out the examples folders with detailed examples for all functionality of this crate.

Add the crossterm_style package to your Cargo.toml file.

[dependencies] crossterm_style = "0.3"

And import the crossterm_style modules you want to use.

```rust
extern crate crossterm_style;

pub use crossterm_style::{color, style, Attribute, Color, ColorType, ObjectStyle, StyledObject, TerminalColor, Colorize, Styler}; ```

Useful Links

Features

These are the features of this crate:

Examples

The examples folder has more complete and verbose examples.

style text with attributes ```rust use crossterm_style::{Colored, Color, Colorize, Styler, Attribute};

// pass any Attribute value to the formatting braces. println!("{} Underlined {} No Underline", Attribute::Underlined, Attribute::NoUnderline);

// you could also call different attribute methods on a &str and keep on chaining if needed. let styledtext = "Bold Underlined".bold().underlined(); println!("{}", styledtext);

// old-way but still usable let styled_text = style("Bold Underlined").bold().underlined(); ```

style text with colors ```rust use crossterm_style::{Colored, Color, Colorize};

println!("{} Red foreground color", Colored::Fg(Color::Red)); println!("{} Blue background color", Colored::Bg(Color::Blue));

// you can also call different coloring methods on a &str. let styledtext = "Bold Underlined".red().onblue(); println!("{}", styled_text);

// old-way but still usable let styled_text = style("Bold Underlined").with(Color::Red).on(Color::Blue); _style text with RGB and ANSI Value_ rust // custom rgb value (Windows 10 and UNIX systems) println!("{} some colored text", Colored::Fg(Color::Rgb { r: 10, g: 10, b: 10 }));

// custom ansi color value (Windows 10 and UNIX systems) println!("{} some colored text", Colored::Fg(Color::AnsiValue(10))); ```

Tested terminals

This crate supports all Unix terminals and windows terminals down to Windows 7 but not all of them have been tested. If you have used this library for a terminal other than the above list without issues feel free to add it to the above list, I really would appreciate it.

Authors

License

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