Coloring
Lip Gloss supports multiple color profiles to style your terminal apps.
Style with Color
Lip Gloss supports a variety of color profiles to bring vibrant, polished visuals to your terminal apps, including those built with Bubble Tea. From basic ANSI colors to true color and adaptive options, Lip Gloss makes styling intuitive and flexible.
Pair Lip Gloss with Bubble Tea to create stunning, styled terminal user interfaces.
Color Profiles
Lip Gloss offers several color profiles to suit different terminal capabilities:
Use 4-bit ANSI colors for basic terminal support:
lipgloss.Color("5") // magenta
lipgloss.Color("9") // red
lipgloss.Color("12") // light blueAccess a wider 8-bit color palette:
lipgloss.Color("86") // aqua
lipgloss.Color("201") // hot pink
lipgloss.Color("202") // orangeUse 24-bit true color (16,777,216 colors) with hex codes:
lipgloss.Color("#0000FF") // good ol' 100% blue
lipgloss.Color("#04B575") // a green
lipgloss.Color("#3C3C3C") // a dark graySpecify colors for light and dark backgrounds, automatically detected at runtime:
lipgloss.AdaptiveColor{Light: "236", Dark: "248"}Define exact values for True Color, ANSI256, and ANSI profiles without automatic degradation:
lipgloss.CompleteColor{TrueColor: "#0000FF", ANSI256: "86", ANSI: "5"}Combine CompleteColor with AdaptiveColor for precise light and dark background styling:
lipgloss.CompleteAdaptiveColor{
Light: CompleteColor{TrueColor: "#d7ffae", ANSI256: "193", ANSI: "11"},
Dark: CompleteColor{TrueColor: "#d75fee", ANSI256: "163", ANSI: "5"},
}Lip Gloss also supports a 1-bit ASCII profile (black and white only) for minimalistic terminals.
How It Works
Lip Gloss makes coloring your terminal output straightforward:
Choose a Color Profile
Select a color profile (e.g., ANSI 16, True Color) based on your terminal’s capabilities. Lip Gloss automatically detects the terminal’s color support.
Apply Colors
Use lipgloss.Color, AdaptiveColor, or CompleteColor in a Style struct to apply colors to text:
style := lipgloss.NewStyle().Foreground(lipgloss.Color("#04B575"))
fmt.Println(style.Render("Styled text!"))Automatic Color Handling
Colors outside the terminal’s palette are coerced to the closest available value. Adaptive colors adjust based on the terminal’s light or dark background.
Ensure your terminal supports the desired color profile (e.g., True Color requires a modern terminal like iTerm2 or Alacritty) to avoid unexpected rendering.
How is this guide?