Copying Styles
Easily copy a set of styles in Lip Gloss for consistent terminal styling.
Copy Styles with Ease
Lip Gloss makes it easy to copy a set of styles, allowing you to reuse and modify styles without affecting the original. Since styles contain only primitive types, assigning a style creates a true copy, perfect for consistent styling in your terminal apps.
Use copied styles with colors, formatting, layout, and borders for cohesive designs.
Copying Options
Lip Gloss provides simple ways to copy and modify styles:
Copy a style using simple assignment:
style := lipgloss.NewStyle().Foreground(lipgloss.Color("219"))
copiedStyle := style // this is a true copyCreate a copy with additional styling applied:
style := lipgloss.NewStyle().Foreground(lipgloss.Color("219"))
wildStyle := style.Blink(true) // this is a true copy, with blink addedHow It Works
Copy styles to streamline your terminal styling:
Create a Base Style
Define a style with properties like color or formatting using lipgloss.NewStyle().
Copy the Style
Assign the style to a new variable to create an independent copy:
style := lipgloss.NewStyle().Foreground(lipgloss.Color("219"))
copiedStyle := style
fmt.Println(copiedStyle.Render("Copied style!"))Modify Copies
Add or change properties on the copied style without affecting the original, as Style structs are immutable by assignment.
Since Style contains only primitive types, copying via assignment ensures the original style remains unchanged, simplifying style management.
How is this guide?