Documentation
¶
Overview ¶
Package lisboa provides a consistent theme system for Bubble Tea v2 TUI applications at Operator Foundation.
Lisboa implements the six-category universal semantic color system (surface, text, subtle, accent, warning, critical) defined in DESIGN.md, with three time-of-day theme variants (Dia, Tarde, Noite) defined in STYLE.md.
Quick Start ¶
Create a theme from Bubble Tea's background color detection:
import (
tea "charm.land/bubbletea/v2"
"charm.land/lipgloss/v2"
"codeberg.org/curiosa/lisboa"
)
type model struct {
theme lisboa.Theme
help help.Model
textarea textarea.Model
}
func (m model) Init() tea.Cmd {
return tea.RequestBackgroundColor
}
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.BackgroundColorMsg:
m.theme = lisboa.NewTheme(lisboa.DiaNoite, msg.IsDark())
m.help.Styles = m.theme.HelpStyles()
m.textarea.Styles = m.theme.TextareaStyles()
}
return m, nil
}
func (m model) View() tea.View {
title := m.theme.TitleStyle().Render(lisboa.AppTitle("EXEMPLO"))
body := m.theme.BodyStyle().Render("Olá, mundo!")
help := m.theme.SubtleStyle().Render("q: sair")
content := lipgloss.JoinVertical(lipgloss.Left, title, body, help)
v := tea.NewView(content)
v.AltScreen = true
v.BackgroundColor = m.theme.Surface
v.ForegroundColor = m.theme.Text
return v
}
Theme Pairs ¶
Lisboa offers two pairing modes that map three variants onto the terminal's binary light/dark signal:
- DiaNoite: Dia (light) ↔ Noite (dark). Works with automatic terminal background detection.
- TardeNoite: Tarde (mid-dark) ↔ Noite (dark). Requires application-controlled switching since both backgrounds are dark.
Direct Variant Selection ¶
For time-based switching or explicit configuration, bypass the pair mechanism:
theme := lisboa.NewThemeVariant(lisboa.Tarde)
Semantic Colors ¶
All Theme fields are image/color.Color values organized into six categories. Use them directly with Lip Gloss v2 styles:
style := lipgloss.NewStyle().
Foreground(theme.Accent).
Background(theme.Surface)
Redundant Encoding ¶
Per DESIGN.md, color must never be the sole carrier of semantic information. Lisboa provides icon constants and style pairs:
fmt.Sprintf("%s %s", lisboa.IconCritical,
theme.StatusStyles().Critical.Render("Connection failed"))
Produces: ✗ Connection failed
Package lisboa provides a consistent theme system for Bubble Tea v2 TUI applications. It implements the six-category universal semantic color system defined in DESIGN.md with three time-of-day variants.
Usage with Bubble Tea v2:
func (m model) Init() tea.Cmd {
return tea.RequestBackgroundColor
}
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.BackgroundColorMsg:
m.theme = lisboa.NewTheme(lisboa.DiaNoite, msg.IsDark())
}
return m, nil
}
Index ¶
- Constants
- func AppTitle(name string) string
- func PaneHeader(title string) string
- type Pair
- type StatusStyle
- type Theme
- func (t Theme) ActiveVariant() Variant
- func (t Theme) BodyStyle() lipgloss.Style
- func (t Theme) FaintStyle() lipgloss.Style
- func (t Theme) FocusedBorderStyle() lipgloss.Style
- func (t Theme) HelpStyles() help.Styles
- func (t Theme) HostnameStyle() lipgloss.Style
- func (t Theme) IsDark() bool
- func (t Theme) ListItemStyles() list.DefaultItemStyles
- func (t Theme) ListStyles() list.Styles
- func (t Theme) LocalUserStyle() lipgloss.Style
- func (t Theme) PlaceholderStyle() lipgloss.Style
- func (t Theme) PromptStyle() lipgloss.Style
- func (t Theme) RemoteUserStyle() lipgloss.Style
- func (t Theme) SecondaryStyle() lipgloss.Style
- func (t Theme) SelectedStyle() lipgloss.Style
- func (t Theme) StatusStyles() StatusStyle
- func (t Theme) SubtleStyle() lipgloss.Style
- func (t Theme) TextareaStyles() textarea.Styles
- func (t Theme) TextinputStyles() textinput.Styles
- func (t Theme) TitleStyle() lipgloss.Style
- func (t Theme) UnfocusedBorderStyle() lipgloss.Style
- func (t Theme) UnselectedStyle() lipgloss.Style
- func (t Theme) ViewportLineStyle(line int) lipgloss.Style
- type Variant
Constants ¶
const ( IconInfo = "ℹ" IconSuccess = "✓" IconWarning = "⚠" IconCritical = "✗" )
Status icon constants for redundant encoding.
const ( PointerSelected = "▸ " PointerUnselected = " " )
Selection pointer constants.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Pair ¶
type Pair int
Pair represents a theme pair mapping two variants onto the terminal's binary light/dark background signal.
const ( // DiaNoite selects Dia for light backgrounds, Noite for dark. // Works with automatic terminal background detection. DiaNoite Pair = iota // TardeNoite selects Tarde for the light branch, Noite for // dark. Both variants have dark backgrounds, so automatic // terminal detection cannot distinguish them. Switching must // be application-controlled (e.g. by system clock or config). TardeNoite )
type StatusStyle ¶
type StatusStyle struct {
// Info renders informational messages: ℹ text
Info lipgloss.Style
// Success renders success messages: ✓ text
Success lipgloss.Style
// Warning renders warning messages: ⚠ text
Warning lipgloss.Style
// Critical renders error messages: ✗ text
Critical lipgloss.Style
}
StatusStyle returns styles for status messages. Each pairs a semantic color with an icon to ensure redundant encoding per DESIGN.md.
type Theme ¶
type Theme struct {
// Surface family — background plane.
Surface color.Color
SurfaceSunken color.Color
SurfaceDeep color.Color
SurfaceRaised color.Color
// Text family — primary readable content.
Text color.Color
TextSecondary color.Color
// Subtle family — de-emphasized content, metadata, borders.
Subtle color.Color
SubtleFaint color.Color
SubtleBorder color.Color
// Accent family — interactive and informational elements.
// Core hue: blue (Oklch 220°–250°).
Accent color.Color
AccentEmphasis color.Color
AccentMuted color.Color
// Accent aesthetic variants. These extend into adjacent hue
// territory (Oklch 180°–280°) and require cor validation to
// confirm they satisfy the variant constraint under all
// dichromacy projections.
AccentPurple color.Color
AccentCyan color.Color
AccentTeal color.Color
// Warning family — caution states requiring attention.
// Core hue: yellow (Oklch 80°–100°).
Warning color.Color
WarningMild color.Color
// Critical family — danger states demanding immediate attention.
// Core hue: red (Oklch 15°–35°).
Critical color.Color
CriticalSevere color.Color
// contains filtered or unexported fields
}
Theme holds resolved semantic colors for a specific variant. All color fields implement image/color.Color.
Colors are organized into six categories per DESIGN.md: surface, text, subtle (achromatic), and accent, warning, critical (chromatic).
func NewTheme ¶
NewTheme creates a theme by selecting a variant from a pair.
For DiaNoite, isDark should come from tea.BackgroundColorMsg.IsDark(). For TardeNoite, isDark should come from application logic (system clock, user configuration, or explicit command) since both variants have dark backgrounds and terminal detection cannot distinguish them.
func NewThemeVariant ¶
NewThemeVariant creates a theme for a specific variant directly, bypassing the pair selection mechanism.
func (Theme) ActiveVariant ¶
ActiveVariant returns the resolved theme variant.
func (Theme) FaintStyle ¶
FaintStyle returns a style for timestamps, metadata, and other tertiary content.
func (Theme) FocusedBorderStyle ¶
FocusedBorderStyle returns a border style for the focused pane.
func (Theme) HelpStyles ¶
HelpStyles returns styles for the help bubble.
func (Theme) HostnameStyle ¶
HostnameStyle returns a style for machine/host names.
func (Theme) ListItemStyles ¶
func (t Theme) ListItemStyles() list.DefaultItemStyles
ListItemStyles returns styles for list items in the list bubble.
func (Theme) ListStyles ¶
ListStyles returns styles for the list bubble.
func (Theme) LocalUserStyle ¶
LocalUserStyle returns a style for the local username. Should be paired with a "(local)" label prefix for redundant encoding.
func (Theme) PlaceholderStyle ¶
PlaceholderStyle returns a style for input placeholder text.
func (Theme) PromptStyle ¶
PromptStyle returns a style for input prompts.
func (Theme) RemoteUserStyle ¶
RemoteUserStyle returns a style for remote usernames. Distinguished from local by the absence of the "(local)" label prefix.
func (Theme) SecondaryStyle ¶
SecondaryStyle returns a style for secondary body text.
func (Theme) SelectedStyle ¶
SelectedStyle returns a style for the currently selected list item. Pairs accent color with bold weight and a pointer glyph.
func (Theme) StatusStyles ¶
func (t Theme) StatusStyles() StatusStyle
StatusStyles returns styles for status messages.
func (Theme) SubtleStyle ¶
SubtleStyle returns a style for de-emphasized content such as help text and keybinding hints.
func (Theme) TextareaStyles ¶
TextareaStyles returns styles for the textarea bubble.
func (Theme) TextinputStyles ¶
TextinputStyles returns styles for the textinput bubble.
func (Theme) TitleStyle ¶
TitleStyle returns a style for the application title bar.
╭─── APPNAME ───╮
func (Theme) UnfocusedBorderStyle ¶
UnfocusedBorderStyle returns a border style for unfocused panes.
func (Theme) UnselectedStyle ¶
UnselectedStyle returns a style for unselected list items.
func (Theme) ViewportLineStyle ¶
ViewportLineStyle returns a function suitable for viewport's StyleLineFunc field. It applies no special per-line styling by default. Applications can wrap this to add line numbers or highlighting using theme colors.
type Variant ¶
type Variant int
Variant represents a theme variant corresponding to a Portuguese time of day.
const ( // Dia is the morning variant with a light background. // Sourced from Catppuccin Latte. Dia Variant = iota // Tarde is the afternoon variant with a mid-dark background. // Sourced from Catppuccin Frappé. Tarde // Noite is the night variant with a dark background. // Sourced from Catppuccin Mocha. Noite )