-
Seed palette with Charmtone (optional but recommended)
import (
"charm.land/lipgloss/v2"
"charm.land/lipgloss/v2/compat"
"github.com/charmbracelet/x/exp/charmtone"
)
type Theme struct {
Primary lipgloss.Color
Secondary lipgloss.Color
Background lipgloss.Color
Text lipgloss.Color
Subtle lipgloss.Color
AccentWarn lipgloss.Color
}
func NewTheme() Theme {
return Theme{
Primary: lipgloss.Color(charmtone.Charple.Hex()),
Secondary: lipgloss.Color(charmtone.Dolly.Hex()),
Background: lipgloss.Color(charmtone.Pepper.Hex()),
Text: lipgloss.Color(charmtone.Ash.Hex()),
Subtle: lipgloss.Color(charmtone.Squid.Hex()),
AccentWarn: lipgloss.Color(charmtone.Zest.Hex()),
}
}
-
Expose ready-made styles
Create methods that return configured lipgloss.Style instances (e.g., base text, muted text, selected rows, border styles). This keeps all components pulling from the same source.
type Styles struct {
Base lipgloss.Style
Muted lipgloss.Style
Title lipgloss.Style
SelectedRow lipgloss.Style
}
func (t Theme) Styles() Styles {
base := lipgloss.NewStyle().Foreground(t.Text)
return Styles{
Base: base,
Muted: base.Foreground(t.Subtle),
Title: base.Foreground(t.Primary).Bold(true),
SelectedRow: base.Foreground(t.Background).Background(t.Primary),
}
}
-
Add gradient helpers when needed
Use lipgloss.Color gradients for headers or logo treatments.
-
Share the theme
Provide a global accessor (e.g. via a package-level var Default Theme) or inject through your Bubble Tea models.