{"name":"Lipgloss: Declarative Terminal Styling for Go Applications","description":"Lipgloss is a powerful Go library by Charmbracelet that provides a declarative way to style terminal output and create beautiful TUI layouts. Inspired by CSS, it simplifies the process of adding colors, borders, padding, and more to your command-line applications. This tool is ideal for developers looking to enhance the visual appeal and user experience of their terminal-based projects.","github":"https://github.com/charmbracelet/lipgloss","url":"https://osrepos.com/repo/charmbracelet-lipgloss","source":"osrepos.com","sourceDescription":"This repository profile is provided by osrepos.com, an open source repository discovery platform.","repositoryProfile":"https://osrepos.com/repo/charmbracelet-lipgloss","generatedFor":"open source discovery and AI-assisted research","markdown":"https://osrepos.com/repo/charmbracelet-lipgloss.md","json":"https://osrepos.com/repo/charmbracelet-lipgloss.json","topics":["cli","go","golang","hacktoberfest","layout","style","tui","terminal-ui"],"keywords":["cli","go","golang","hacktoberfest","layout","style","tui","terminal-ui"],"stars":null,"summary":"Lipgloss is a powerful Go library by Charmbracelet that provides a declarative way to style terminal output and create beautiful TUI layouts. Inspired by CSS, it simplifies the process of adding colors, borders, padding, and more to your command-line applications. This tool is ideal for developers looking to enhance the visual appeal and user experience of their terminal-based projects.","content":"## Introduction\n\nLipgloss, from the creators at Charmbracelet, is a robust Go library designed to bring elegant and structured styling to your terminal applications. It offers a declarative, CSS-like approach to defining styles, making it intuitive for developers to create visually appealing layouts and text. Whether you're building a simple CLI tool or a complex Terminal User Interface (TUI), Lipgloss provides the tools to make your output shine.\n\n## Installation\n\nTo integrate Lipgloss into your Go project, simply use the `go get` command:\n\nbash\ngo get github.com/charmbracelet/lipgloss\n\n\n## Examples\n\nLipgloss offers a wide array of styling options, from basic text formatting to complex layout management.\n\n### Basic Styling\n\nDefine styles with methods like `Bold`, `Foreground`, `Background`, and `Padding`.\n\ngo\nimport \"github.com/charmbracelet/lipgloss\"\n\nvar style = lipgloss.NewStyle().\n    Bold(true).\n    Foreground(lipgloss.Color(\"#FAFAFA\")).\n    Background(lipgloss.Color(\"#7D56F4\")).\n    PaddingTop(2).\n    PaddingLeft(4).\n    Width(22)\n\nfmt.Println(style.Render(\"Hello, kitty\"))\n\n\n### Colors\n\nLipgloss supports various color profiles, automatically degrading colors if the terminal doesn't support the full range.\n\n*   **ANSI 16 colors (4-bit)**\n    go\nlipgloss.Color(\"5\")  // magenta\nlipgloss.Color(\"9\")  // red\nlipgloss.Color(\"12\") // light blue\n    \n*   **ANSI 256 Colors (8-bit)**\n    go\nlipgloss.Color(\"86\")  // aqua\nlipgloss.Color(\"201\") // hot pink\nlipgloss.Color(\"202\") // orange\n    \n*   **True Color (24-bit)**\n    go\nlipgloss.Color(\"#0000FF\") // good ol' 100% blue\nlipgloss.Color(\"#04B575\") // a green\nlipgloss.Color(\"#3C3C3C\") // a dark gray\n    \n*   **Adaptive Colors**: Specify colors for light and dark backgrounds.\n    go\nlipgloss.AdaptiveColor{Light: \"236\", Dark: \"248\"}\n    \n\n### Inline Formatting\n\nApply common ANSI text formatting options.\n\ngo\nvar style = lipgloss.NewStyle().\n    Bold(true).\n    Italic(true).\n    Faint(true).\n    Blink(true).\n    Strikethrough(true).\n    Underline(true).\n    Reverse(true)\n\n\n### Block-Level Formatting\n\nControl spacing with padding and margins, similar to CSS.\n\ngo\n// Padding shorthand\nlipgloss.NewStyle().Padding(2) // 2 cells on all sides\n\n// Margins shorthand\nlipgloss.NewStyle().Margin(2, 4) // 2 cells top/bottom, 4 cells left/right\n\n\n### Borders\n\nEasily add various border styles, colors, and positions.\n\ngo\n// Add a purple, rectangular border\nvar style = lipgloss.NewStyle().\n    BorderStyle(lipgloss.NormalBorder()).\n    BorderForeground(lipgloss.Color(\"63\"))\n\n// Set a rounded, yellow-on-purple border to the top and left\nvar anotherStyle = lipgloss.NewStyle().\n    BorderStyle(lipgloss.RoundedBorder()).\n    BorderForeground(lipgloss.Color(\"228\")).\n    BorderBackground(lipgloss.Color(\"63\")).\n    BorderTop(true).\n    BorderLeft(true)\n\n\n### Joining Paragraphs\n\nCombine text blocks horizontally or vertically with alignment options.\n\ngo\n// Horizontally join three paragraphs along their bottom edges\nlipgloss.JoinHorizontal(lipgloss.Bottom, paragraphA, paragraphB, paragraphC)\n\n// Vertically join two paragraphs along their center axes\nlipgloss.JoinVertical(lipgloss.Center, paragraphA, paragraphB)\n\n\n### Rendering Tables\n\nThe `lipgloss/table` sub-package allows for structured data presentation.\n\ngo\nimport \"github.com/charmbracelet/lipgloss/table\"\n\nrows := [][]string{\n    {\"Chinese\", \"??\", \"??\"},\n    {\"Japanese\", \"?????\", \"??\"},\n}\n\nt := table.New().\n    Border(lipgloss.NormalBorder()).\n    Headers(\"LANGUAGE\", \"FORMAL\", \"INFORMAL\").\n    Rows(rows...)\n\nfmt.Println(t)\n\n\n### Rendering Lists\n\nCreate formatted lists with the `lipgloss/list` sub-package, supporting nesting and custom enumerators.\n\ngo\nimport \"github.com/charmbracelet/lipgloss/list\"\n\nl := list.New(\"A\", \"B\", \"C\")\nfmt.Println(l)\n\n// Nested list example\nl = list.New(\n    \"A\", list.New(\"Artichoke\"),\n    \"B\", list.New(\"Baking Flour\", \"Bananas\"),\n)\nfmt.Println(l)\n\n\n### Rendering Trees\n\nVisualize hierarchical data using the `lipgloss/tree` sub-package.\n\ngo\nimport \"github.com/charmbracelet/lipgloss/tree\"\n\nt := tree.Root(\".\").\n    Child(\"A\", \"B\", \"C\")\nfmt.Println(t)\n\n// Nested tree example\nt = tree.Root(\".\").\n    Child(\"macOS\").\n    Child(\n        tree.New().\n            Root(\"Linux\").\n            Child(\"NixOS\"),\n    )\nfmt.Println(t)\n\n\n## Why Use Lipgloss?\n\nLipgloss simplifies the creation of rich, engaging terminal interfaces. Its declarative API, inspired by web styling, allows developers to focus on the structure and content of their applications rather than the complexities of ANSI escape codes. It automatically handles color degradation, supports adaptive colors for different terminal themes, and provides powerful layout utilities. For those building TUIs with [Bubble Tea](https://github.com/charmbracelet/tea), Lipgloss is an excellent companion for crafting beautiful views.\n\n## Links\n\n*   **GitHub Repository**: [https://github.com/charmbracelet/lipgloss](https://github.com/charmbracelet/lipgloss){:target=\"_blank\"}\n*   **GoDoc Documentation**: [https://pkg.go.dev/github.com/charmbracelet/lipgloss?tab=doc](https://pkg.go.dev/github.com/charmbracelet/lipgloss?tab=doc){:target=\"_blank\"}","metrics":{"detailViews":7,"githubClicks":3},"dates":{"published":null,"modified":"2025-11-14T16:01:36.000Z"}}