lacquer 0.1.1

Style definitions for gorgeous terminal layouts ๐Ÿ’…
Documentation

What is Lacquer?

Lacquer is the Rust equivalent of lipgloss from Charmbracelet. It provides declarative style definitions for building beautiful terminal layoutsโ€”with padding, margins, borders, colors, and alignment.

use lacquer::{Style, Border, Position, Color};

let style = Style::new()
    .padding(1, 2)
    .margin(1, 0)
    .border(Border::Rounded)
    .border_foreground(Color::from_hex("#7C3AED"))
    .foreground(Color::from_hex("#FAFAFA"))
    .bold()
    .align(Position::Center);

println!("{}", style.render("๐Ÿ”ฅ Molten Labs"));
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚                    โ”‚
โ”‚   ๐Ÿ”ฅ Molten Labs   โ”‚
โ”‚                    โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

Features

๐Ÿ“ฆ Box Model

  • Padding (all sides or individual)
  • Margins (all sides or individual)
  • Width/height constraints
  • Max width/height limits

๐ŸŽจ Colors & Styling

  • Foreground & background colors
  • Full RGB/hex color support
  • Bold, italic, underline, dim
  • Strikethrough, reverse video

๐Ÿ”ฒ Borders

  • 8 built-in styles (Rounded, Double, Thick...)
  • Custom border characters
  • Per-side border colors
  • ASCII fallback option

๐Ÿ“ Layout & Alignment

  • Horizontal alignment (left, center, right)
  • Vertical alignment (top, center, bottom)
  • Inline mode for no-wrap rendering
  • Unicode-aware width calculation

Installation

cargo add lacquer

Or add to your Cargo.toml:

[dependencies]
lacquer = "0.1"

Quick Start

Basic Styling

use lacquer::{Style, Color};

// Simple colored text
let styled = Style::new()
    .foreground(Color::from_hex("#F97316"))
    .bold()
    .render("Hello, Lacquer!");

println!("{}", styled);

Box with Padding

use lacquer::{Style, Border};

let box_style = Style::new()
    .padding(1, 3)          // 1 vertical, 3 horizontal
    .border(Border::Rounded)
    .render("Content");

println!("{}", box_style);
// โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
// โ”‚             โ”‚
// โ”‚   Content   โ”‚
// โ”‚             โ”‚
// โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

Centered Content

use lacquer::{Style, Border, Position};

let centered = Style::new()
    .width(30)
    .border(Border::Double)
    .align(Position::Center)
    .render("Centered!");

println!("{}", centered);
// โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
// โ•‘          Centered!         โ•‘
// โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

Multiple Lines

use lacquer::{Style, Border, Color};

let content = "Line 1\nLine 2\nLine 3";

let multiline = Style::new()
    .padding(1, 2)
    .border(Border::Thick)
    .foreground(Color::Green)
    .render(content);

println!("{}", multiline);

Border Styles

use lacquer::Border;

Border::None      // No border
Border::Normal    // โ”Œโ”€โ”€โ” โ”‚ โ””โ”€โ”€โ”˜
Border::Rounded   // โ•ญโ”€โ”€โ•ฎ โ”‚ โ•ฐโ”€โ”€โ•ฏ
Border::Thick     // โ”โ”โ”โ”“ โ”ƒ โ”—โ”โ”โ”›
Border::Double    // โ•”โ•โ•โ•— โ•‘ โ•šโ•โ•โ•
Border::Ascii     // +--+ | +--+
Border::Block     // โ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆ
Border::Dashed    // โ”Œโ•Œโ•Œโ” โ•Ž โ””โ•Œโ•Œโ”˜

Custom Borders

use lacquer::{Border, BorderStyle};

let custom = Border::Custom(BorderStyle::new(
    'โ•ญ', 'โ”€', 'โ•ฎ',  // top-left, top, top-right
    'โ”‚',            // right
    'โ•ฏ', 'โ”€', 'โ•ฐ',  // bottom-right, bottom, bottom-left
    'โ”‚',            // left
));

Inline Mode

For styling without block rendering (no borders, no padding):

use lacquer::{Style, Color};

let inline = Style::new()
    .foreground(Color::Red)
    .bold()
    .inline()
    .render("Error!");

println!("Status: {}", inline);
// Status: Error! (styled red and bold)

Using with Molten Brand

Enable the brand feature for pre-defined colors:

[dependencies]
lacquer = { version = "0.1", features = ["brand"] }
use lacquer::{Style, Border};
use molten_brand::{colors, products};

let goblin_box = Style::new()
    .border(Border::Rounded)
    .border_foreground(products::lair::PRIMARY.into())
    .foreground(colors::text::PRIMARY.into())
    .render("Lair Terminal");

Why "Lacquer"?

In the forge, lacquer is the hard, protective finish applied to metalworkโ€”transforming raw iron into polished, beautiful artifacts. This library does the same for your terminal output. ๐Ÿ’…


Ecosystem

Lacquer is part of the Molten Labs open source ecosystem:

Crate Description Status
molten_brand Design tokens & colors โœ… Published
glyphs ANSI escape sequences โœ… Published
lacquer Terminal styling (you are here) โœ… Published
cauldron TUI framework (like bubbletea) ๐Ÿ“‹ Planned

Documentation


Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

git clone https://github.com/moltenlabs/lacquer
cd lacquer
cargo test

License

Licensed under either of:

at your option.