explaingit

charmbracelet/lipgloss

11,254GoAudience · developerComplexity · 2/5Setup · easy

TLDR

Lip Gloss is a Go library for adding colors, borders, padding, and column layouts to command-line tool output using a CSS-inspired API that automatically adapts to the user's terminal color capabilities.

Mindmap

mindmap
  root((repo))
    What it does
      Text styling
      Color output
      Layout and borders
    Design
      CSS inspired API
      Style inheritance
      Color auto downgrade
    Features
      Padding and margins
      Text alignment
      Border styles
    Ecosystem
      Charm toolchain
      Bubble Tea
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Add colored text, bold formatting, and styled borders to a Go CLI tool's output without writing raw terminal escape codes

USE CASE 2

Build neatly aligned, padded column layouts for a terminal dashboard or table display using Lip Gloss's block layout features

USE CASE 3

Define reusable text styles in Go that automatically downgrade their colors on terminals with limited color support

USE CASE 4

Create consistent visual themes for a Bubble Tea terminal app by sharing Lip Gloss style definitions across components

Tech stack

Go

Getting it running

Difficulty · easy Time to first run · 30min

In plain English

Lip Gloss is a Go library for styling text in terminal applications. If you have ever seen a command-line tool with colored output, neatly aligned columns, bordered boxes, or other visual formatting, that kind of output is built using libraries like this one. Lip Gloss handles all of the low-level terminal codes needed to produce those effects and exposes them through a simple, readable Go API. The design takes inspiration from CSS, the language used to style web pages. You create a style object, chain properties onto it like bold, foreground color, padding, and width, and then apply it to a string of text. Developers familiar with web styling will find the approach recognizable. Styles can inherit from other styles, and properties cascade in a way similar to how CSS inheritance works. Color support is handled gracefully across different terminal environments. You can specify colors as hex codes, standard ANSI color numbers, or 256-color values. If the user's terminal does not support the full color range you specified, Lip Gloss automatically downgrades to the best available option rather than producing broken output. Beyond text color and decoration, the library supports block-level layout features: padding, margins, minimum widths and heights, text alignment, and a variety of border styles including rounded, thick, double, and custom. It also provides utilities for working with colors mathematically, such as darkening, lightening, or finding complementary colors. Lip Gloss is part of the Charm toolchain, a collection of Go libraries aimed at making terminal user interfaces easier to build. It works alongside Bubble Tea, which is Charm's framework for building interactive terminal applications.

Copy-paste prompts

Prompt 1
Using Lip Gloss in Go, how do I create a style with a rounded border, padding, and a specific hex color for a CLI status panel?
Prompt 2
How do I build a multi-column terminal layout in Go using Lip Gloss with different widths and text alignment for each column?
Prompt 3
I want my Go CLI tool's colored output to degrade gracefully on terminals that do not support 256 colors, how does Lip Gloss handle that automatically?
Prompt 4
How do Lip Gloss styles inherit from each other and how do I cascade style properties across components, similar to CSS inheritance?
Open on GitHub → Explain another repo

← charmbracelet on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.