
Color your terminal without typing whatever the heck '\x1b[31m' is.
[!WARNING] Farben, in this current state, is unstable. It only has a few public interfaces, unfinished features, and is experimental. I do not recommend using it in production, at least not yet.
What Is Farben
Look at the tagline up there ^
Documentation
- User Guide: https://razkar-studio.github.io/farben
- API Reference: https://docs.rs/farben
Usage
// Using no features
use *;
style!;
style!;
cprintln!;
cprintln!;
cprintln!;
let name = "Razkar";
cprintln!;
cprintb!;
cprintln!;
// Using the "compile" feature
use *;
style!;
cprintln!; // compile-time validation
cprintln!;
let name = "Razkar";
cprintln!;
cprintb!;
cprintln!;
Features
- Markup-like Syntax: Easy to read, write, and powerful when used.
- Zero required runtime dependencies: Only
farben-coreas a path dependency, Farben introduces no complicated dependency tree. - Opt-in Compile-time Processing: Validate and process markup at compile time with no runtime overhead, via the
compilefeature flag. - Complete Toolkit: Named colors, ANSI256, RGB, emphasis styles, style chaining, foreground and background support.
- Drop-in Print Macros:
cprint!,cprintln!,cprintb!, andcprintbln!work just likeprint!andprintln!but with markup support. - Bleed Variants:
cprintb!,cprintbln!,colorb(), andcolorb!()skip the trailing reset, letting styles carry forward across multiple calls. - User-defined styles: Define your own tags with
style!()that expand to any combination of supported tags.- Features shouldn't be forced upon you: Opt-out from user-defined styles at anytime, making Farben lighter and easier to work with.
- Format using
prefix!(): Your styles, your rules. Make a prefix to go along with it, calling your custom style will resolve to the prefix you define.
Syntax
Tags are written as [tag] and apply from that point forward. Multiple tags can be combined in a single bracket: [bold red].
[!WARNING] Spaces inside
ansi()andrgb()are not supported at the moment.
| Tag | Description |
|---|---|
[red], [blue], ... |
Named colors (black, red, green, yellow, blue, magenta, cyan, white) |
[fg:red], [bg:red] |
Explicit foreground/background color — works with all color formats |
[rgb(r,g,b)] |
24-bit RGB color |
[ansi(n)] |
256-color palette index |
[bold], [italic], [dim], [underline], [blink], [strikethrough] |
Emphasis styles |
[/] |
Reset all styles |
\\[ |
Escaped bracket, treated as literal [ |
[yourname] |
User-defined style via style!() |
Error Handling
color() panics on invalid markup. For graceful error handling, use try_color():
use try_color;
match try_color
Contributing
Contributions are welcome! Feel free to submit a Pull Request.
License
This project is protected under the RazkarStudio Permissive License (RSPL). See LICENSE.md for more details.
Cheers, RazkarStudio.
© 2026 RazkarStudio. All rights reserved.