12 releases

0.1.3 Jul 30, 2022
0.1.2 Jul 24, 2022
0.0.7 Jul 24, 2022
0.0.0 May 29, 2020

#324 in Command-line interface

40 downloads per month
Used in 2 crates

MIT/Apache

1MB
605 lines

kimono

docs.rs docs

A terminal style toolkit inspired by CSS and lipgloss for truecolor 24-bit terminals. Made for elegant TUIs.

Screen Shot 2022-07-30 at 10 57 29 AM

Image terminal rendering done by our sister project ukiyeo.

cargo add kimono

Examples

Text can be styled.

use kimono::*;

const STYLE: Style = Style::new().bold().color(0x91b984);

fn main() {
    STYLE.render("こんにちは");
}

Unicode text can be padded, bordered, and positioned.

Screen Shot 2022-07-23 at 5 01 28 PM
use kimono::*;

const STYLE: Style = Style::new()
    .padding_top(1)
    .padding_left(1)
    .padding_right(2)
    .padding_bottom(3)
    .border(1)
    .border_style(BORDER_STYLE_OUTLINE)
    .border_color(0xddae74)
    .border_background(0xbc5633)
    .color(0xebdeb8)
    .background(0x407955);

fn main() {
    clear_screen();
    STYLE.render_at_position(10, 3, "着物");
    print!("\n\r");
}

Text can be constrained to width and/or height.

Screen Shot 2022-07-23 at 9 17 45 PM
use kimono::*;

const STYLE: Style = Style::new()
    .padding(1)
    .color(0xfffd7c)
    .width(8)
    .background(0x956471);

fn main() {
    clear_screen();
    STYLE.render_at_position(10, 3, "abcdefghijklmno");
    print!("\n\r");
}

Text can be measured.

(8, 5)
use kimono::*;

const STYLE: Style = Style::new()
    .padding(1)
    .color(0xfffd7c)
    .width(8)
    .background(0x956471);

fn main() {
    println!("{:?}", STYLE.measure("abcdefghijklmno"));
}

Borders have advanced styling.

Screen Shot 2022-07-24 at 1 31 08 PM
use kimono::*;

const STYLE: Style = Style::new()
    .padding(1)
    .color(0xe46281)
    .background(0xc50f47)
    .border(1)
    .italic()
    .border_style(BorderStyle {
        top_left: None,
        top: Some(''),
        top_right: None,
        left: Some(''),
        right: Some(''),
        bottom_left: None,
        bottom: Some(''),
        bottom_right: None,
        bold: true,
        italic: false,
        underline: false,
        strikethrough: false,
    })
    .border_color(0xe5c7c9)
    .border_background(0x9e1d49);

fn main() {
    clear_screen();
    STYLE.render_at_position(10, 3, "The Tale of Genji by 紫 式部");
    print!("\n\r");
}

Text can be aligned.

Screen Shot 2022-07-30 at 2 10 38 PM
use kimono::*;

const STYLE: Style = Style::new()
    .padding(1)
    .color(0xb1a49a)
    .background(0xea664d)
    .border(1)
    .width(30)
    .text_align(TextAlign::Center);

fn main() {
    clear_screen();
    STYLE.render_at_position(10, 3, "sun egg mango");
    print!("\n\r");
}

Art

Kimono patterns inspired from Unix terminals.

1658677463667

1658677463603

1658677461856

License

This project is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in kimono by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~1–11MB
~62K SLoC