rnk-style 0.1.0

Standalone terminal styling library - style text without the full TUI framework
Documentation
  • Coverage
  • 100%
    2 out of 2 items documented1 out of 1 items with examples
  • Size
  • Source code size: 23.6 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 353.1 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2s Average build duration of successful builds.
  • all releases: 2s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • majiayu000/rnk
    14 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • majiayu000

rnk-style

Standalone terminal styling library for Rust. Style your terminal output without the full TUI framework.

Inspired by Lip Gloss.

Features

  • Chainable API: Fluent style building with .fg(), .bg(), .bold(), etc.
  • Color Support: ANSI 16, ANSI 256, and RGB/Hex colors
  • Text Formatting: Bold, italic, underline, strikethrough, dim, inverse
  • Layout: Padding, margin, borders with multiple styles
  • Alignment: Left, center, right text alignment
  • Zero Dependencies: Only unicode-width for proper character width handling

Quick Start

use rnk_style::{Style, Color};

fn main() {
    let style = Style::new()
        .fg(Color::Cyan)
        .bg(Color::Black)
        .bold()
        .padding(1, 2)
        .border(BorderStyle::Round);

    println!("{}", style.render("Hello, World!"));
}

Examples

Basic Styling

use rnk_style::{Style, Color};

// Simple colored text
let error = Style::new().fg(Color::Red).bold();
println!("{}", error.render("Error: Something went wrong"));

// With background
let highlight = Style::new()
    .fg(Color::Black)
    .bg(Color::Yellow);
println!("{}", highlight.render("Important!"));

Padding and Borders

use rnk_style::{Style, Color, BorderStyle};

let box_style = Style::new()
    .padding(1, 2)
    .border(BorderStyle::Round)
    .border_fg(Color::Cyan);

println!("{}", box_style.render("Boxed content"));

Preset Styles

use rnk_style::Style;

println!("{}", Style::error().render("Error message"));
println!("{}", Style::success().render("Success!"));
println!("{}", Style::warning().render("Warning..."));
println!("{}", Style::info().render("Info"));

Hex Colors

use rnk_style::{Style, Color};

let style = Style::new()
    .fg(Color::hex("#ff6b6b"))
    .bg(Color::hex("#2d3436"));

println!("{}", style.render("Custom colors"));

License

MIT