Charm Bracelet
Layout & Rules

Rules

Easily enforce or unset style rules in Lip Gloss for precise terminal styling.

Control Style Rules

Lip Gloss allows you to easily enforce or unset style rules, giving you precise control over your terminal output. Whether removing styles like bold or enforcing layout constraints like inline rendering, Lip Gloss ensures your UI respects its intended design.

Combine rule management with colors, formatting, and inheritance for cohesive terminal apps.

Rule Management Options

Lip Gloss provides tools to unset or enforce style rules:

Remove any style rule using unset methods, preventing inheritance or copying:

var style = lipgloss.NewStyle().
    Bold(true). // make it bold
    UnsetBold(). // jk don't make it bold
    Background(lipgloss.Color("227")). // yellow background
    UnsetBackground() // never mind

Enforce specific layout constraints for consistent rendering:

// Force rendering onto a single line, ignoring margins, padding, and borders.
someStyle.Inline(true).Render("yadda yadda")

// Also limit rendering to five cells
someStyle.Inline(true).MaxWidth(5).Render("yadda yadda")

// Limit rendering to a 5x5 cell block
someStyle.MaxWidth(5).MaxHeight(5).Render("yadda yadda")

How It Works

Manage style rules to refine your terminal output:

Unset Rules

Use methods like UnsetBold() or UnsetBackground() to remove specific styles, ensuring they aren’t inherited or copied.

Enforce Rules

Apply constraints like Inline(true), MaxWidth, or MaxHeight to control rendering:

style := lipgloss.NewStyle().
    Inline(true).
    MaxWidth(5)
fmt.Println(style.Render("Short text"))

Combine with Other Styles

Pair unset or enforced rules with colors, formatting, or inheritance for precise UI control.

Unsetting rules prevents them from being inherited or copied, making it ideal for managing complex style hierarchies in components.

How is this guide?