lipgloss 0.0.7

Style definitions for nice terminal layouts. The core of the lipgloss-rs library.
Documentation

Lipgloss - Terminal styling made simple and delightful

Lipgloss is a Rust port of the popular Go library for styling terminal layouts and building Terminal User Interfaces (TUIs). It provides a comprehensive set of tools for creating beautiful, styled terminal output with support for colors, borders, alignment, positioning, and complex layout management.

Features

  • Rich styling: Colors (ANSI 16, 256, and true color), bold, italic, underline, strikethrough
  • Flexible layouts: Horizontal and vertical joining, precise positioning
  • Border system: Multiple built-in border styles with customization options
  • Color profiles: Automatic adaptation to terminal capabilities
  • Unicode support: Proper handling of wide characters and emojis
  • Composable design: Chain styles and combine multiple elements seamlessly

Quick Start

use lipgloss::{Style, Color, rounded_border};

// Create a styled text block
let style = Style::new()
    .foreground(Color("205".to_string()))
    .background(Color("235".to_string()))
    .padding(1, 2, 1, 2)
    .border(rounded_border())
    .border_foreground(Color("63".to_string()));

let rendered = style.render("Hello, Lipgloss!");
println!("{}", rendered);

Core Modules

  • [style] - Core styling functionality and the main Style struct
  • [color] - Color definitions and terminal color profile management
  • [mod@gradient] - Color gradients and 2D color grids for advanced styling
  • [border] - Border styles and customization
  • [mod@align] - Text alignment utilities
  • [position] - Positioning and placement functions
  • [join] - Horizontal and vertical layout joining
  • [mod@size] - Dimension measurement and calculation
  • [whitespace] - Styled whitespace and filler generation
  • [renderer] - Terminal rendering and color profile detection

Advanced Usage

Complex layouts with multiple components:

use lipgloss::{Style, Color, join_horizontal, join_vertical, normal_border, CENTER, LEFT, TOP};

let header = Style::new()
    .align_horizontal(CENTER)
    .foreground(Color("86".to_string()))
    .render("Application Title");

let left_panel = Style::new()
    .width(30)
    .padding(1, 2, 1, 2)
    .border(normal_border())
    .render("Left content");

let right_panel = Style::new()
    .width(30)
    .padding(1, 2, 1, 2)
    .border(normal_border())
    .render("Right content");

let body = join_horizontal(TOP, &[&left_panel, &right_panel]);
let layout = join_vertical(LEFT, &[&header, &body]);

println!("{}", layout);

This crate maintains API compatibility with the original Go implementation while following Rust idioms and leveraging Rust's type system for safer terminal styling.