theme

package
v0.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package theme collapses every color used by more than one tuilib component into a single struct. Components still accept raw lipgloss values — theme just makes the common case (one palette, many components) a one-liner.

Usage:

th := theme.Dark()
bc := breadcrumb.New(th.Breadcrumb())                     // header
h  := help.New(th.Help())                                 // inline hints
sb := statusbar.New(th.Statusbar(h.ShortView(), "v0.1.0")) // footer
p  := pane.New(th.Pane())                                 // body

Anything you need to override — a non-default border shape, a slot-brackets style, a custom width — you set on the returned Options before passing it to each component's New. Theme only fills in the color/style tokens.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Base16

type Base16 struct {
	Base00, Base01, Base02, Base03, Base04, Base05, Base06, Base07,
	Base08, Base09, Base0A, Base0B, Base0C, Base0D, Base0E, Base0F string
}

Base16 is Chris Kempson's 16-color scheme format (github.com/chriskempson/ base16). Each slot has a well-defined semantic role, which is what makes it clean to map onto our Theme struct.

Slot reference (abridged):

base00  default background
base01  lighter background — status bars, line numbers
base02  selection background
base03  comments, invisibles, line highlighting
base04  dark foreground (status bars)
base05  default foreground
base06  light foreground
base07  lightest background
base08  red       (variables, errors)
base09  orange    (integers, constants)
base0A  yellow    (classes, search hits)
base0B  green     (strings, diff inserted)
base0C  cyan      (support, regex, escapes)
base0D  blue      (functions, methods)
base0E  magenta   (keywords, storage)
base0F  brown     (deprecated, embedded tags)

Hex values are stored WITHOUT the leading "#" — the converter adds it.

type Theme

type Theme struct {
	// Name is a short identifier for debugging / theme pickers.
	Name string

	// BarBG / BarFG are the shared surface colors for the breadcrumb header,
	// the status bar footer, and anything embedded in them (help hints).
	// Must be a single pair so the strip reads as one continuous band.
	BarBG lipgloss.TerminalColor
	BarFG lipgloss.TerminalColor

	// Current is the emphasis color for the active crumb / current selection.
	Current lipgloss.TerminalColor
	// Muted is for past crumbs and secondary text on the bar.
	Muted lipgloss.TerminalColor
	// Subtle is for separators and faint chrome.
	Subtle lipgloss.TerminalColor

	// KeyFG colors the key labels inside help hints (bold).
	KeyFG lipgloss.TerminalColor

	// BorderActive / BorderInactive color pane borders.
	BorderActive   lipgloss.TerminalColor
	BorderInactive lipgloss.TerminalColor

	// Info / Error style the statusbar's middle slot in each message state.
	InfoBG, InfoFG   lipgloss.TerminalColor
	ErrorBG, ErrorFG lipgloss.TerminalColor

	// Accent is a bold highlight for body content (not used by chrome).
	// Exposed here so screens can reach for it without redeclaring a color.
	Accent lipgloss.TerminalColor
}

Theme is a named palette. Every field is a color token consumed by one or more components. Most tokens have a single semantic role so swapping themes is a matter of rewriting this struct.

func Accent

func Accent() Theme

Accent is a variant with a colored header strip — the same scheme as rendercheck variant 2. Good for apps where the header should pop.

func All

func All() []Theme

All returns every built-in theme, in display order. Handy for theme pickers and examples/themecheck.

func Base16Eighties

func Base16Eighties() Theme

Base16Eighties — Chris Kempson, bright retro palette.

func Base16Ocean

func Base16Ocean() Theme

Base16Ocean — Chris Kempson's "ocean" scheme, blue-grey neutral.

func Base16Railscasts

func Base16Railscasts() Theme

Base16Railscasts — warm muted palette derived from the classic TextMate theme.

func Base16TomorrowNight

func Base16TomorrowNight() Theme

Base16TomorrowNight — Chris Kempson's "tomorrow-night". Balanced dark.

func ByName

func ByName(themes []Theme, name string) (Theme, bool)

ByName looks up a theme by its Name field. Returns false when no theme in themes matches — caller decides what fallback means (typically: leave the existing default in place).

func CatppuccinLatte

func CatppuccinLatte() Theme

CatppuccinLatte — catppuccin.com, light "latte" flavor.

func CatppuccinMocha

func CatppuccinMocha() Theme

CatppuccinMocha — catppuccin.com, dark "mocha" flavor.

func Dark

func Dark() Theme

Dark is the default palette used across the examples — matches pug's look.

func Dracula

func Dracula() Theme

Dracula is the Dracula palette mapped to 256-color — saturated pinks and purples on a near-black surface. Good for "this tool is fun to use."

func EverforestDark

func EverforestDark() Theme

EverforestDark — sainnhe/everforest, medium-contrast dark.

func FromBase16

func FromBase16(name string, p Base16) Theme

FromBase16 maps a Base16 palette onto a Theme. The mapping is opinionated:

BarBG   base01   lighter bg — the canonical status-bar surface
BarFG   base05   default fg
Current base06   light fg for emphasis (bolded by the crumb style)
Muted   base04   dark fg (statusbar-muted)
Subtle  base03   comment grey
KeyFG   base0D   blue (functions/links/URLs — reads as "interactive")
Info    base0B (green) on base00
Error   base08 (red)   on base07
Accent  base0E   keyword color — body-content highlight

If the resulting theme reads wrong for a specific palette (some base16 schemes have an unusually bright base04 or near-identical base01/base00), derive a one-off Theme by hand instead of using this converter.

func Gruvbox

func Gruvbox() Theme

Gruvbox maps Pavel Pertsev's gruvbox-dark palette — warm earthy tones.

func Light

func Light() Theme

Light inverts Dark: pale bars with dark text. Key/border lean teal so the interactive bits stay legible against the light surface.

func Monokai

func Monokai() Theme

Monokai — the classic Sublime Text / TextMate palette.

func Nord

func Nord() Theme

Nord is the Nord palette (arcticicestudio/nord) mapped to 256-color. Cool frost tones; reads calmer than Dark.

func OneDark

func OneDark() Theme

OneDark — Atom's classic "One Dark" palette.

func Resolve

func Resolve(themes []Theme, envVar string) []Theme

Resolve picks an initial theme from themes using, in order:

  1. The named environment variable (envVar) if set.
  2. The Theme field in $XDG_CONFIG_HOME/tuilib/config.yaml (via config.Load).
  3. themes[0] (no change).

Returns themes reordered so the picked theme is first, satisfying app.Options.Themes[0] = initial. Lookup misses (unknown theme name, unreadable config) fall through silently — config and env vars are hints, not errors. To surface a malformed config file, call config.Load directly.

Pass envVar = "" to disable env-var resolution.

Most apps don't need to call this directly: app.New runs Resolve on Options.Themes by default (using Options.ThemeEnvVar). Call it yourself only when you need the resolved order outside the app shell, or when you've set Options.SkipConfig = true to bypass app.New's automatic resolution. Calling Resolve twice is safe — the operation is idempotent.

func RosePine

func RosePine() Theme

RosePine — rosepinetheme.com, main "moon" is excluded; this is the dark default.

func RosePineDawn

func RosePineDawn() Theme

RosePineDawn — rosepinetheme.com, light variant.

func Solarized

func Solarized() Theme

Solarized maps Ethan Schoonover's solarized-dark palette onto the 256-color approximation. Warm text on a deep blue-green surface.

func Terminal

func Terminal() Theme

Terminal builds a Theme from the user's terminal colorscheme — the actual foreground and background are queried via OSC 10/11 (termenv does the raw-mode handshake), and the rest of the Theme uses ANSI color indices 0–15, which the terminal renders using its configured 16-color palette. So a user with Catppuccin configured at the terminal level gets a Catppuccin-colored tuilib UI, with no further config.

Falls back to Dark() or Light() (chosen by lipgloss's background- brightness guess) if stdin/stdout isn't a TTY or the terminal doesn't reply — typical failure modes: piped output, CI, Apple Terminal.app.

Call BEFORE tea.NewProgram.Run(). termenv needs stdin to read the replies, and bubbletea takes ownership of stdin once Run begins.

func TokyoNight

func TokyoNight() Theme

TokyoNight — enkia/tokyo-night, "night" variant.

func (Theme) Alert

func (t Theme) Alert() alert.Options

Alert returns alert.Options pre-filled from the theme — OK button in Accent (bold), message body in BarFG, neutral active/inactive border colors. The chrome is intentionally neutral; for an error-styled alert, override ActiveColor with t.ErrorBG (and OKStyle's foreground with t.ErrorBG) after this builder. Set Width, Height, Title, Message, and OK label as needed before passing to alert.New.

func (Theme) Breadcrumb

func (t Theme) Breadcrumb() breadcrumb.Options

Breadcrumb returns breadcrumb.Options pre-filled from the theme. Mutate the returned value for any non-theme fields (Width, Crumbs, Separator, …).

func (Theme) Confirm

func (t Theme) Confirm() confirm.Options

Confirm returns confirm.Options pre-filled from the theme — selected button in Accent (bold), unselected in Muted, message body in BarFG, border colors matching pane. Set Width, Height, Title, Message, Confirm/Cancel labels, and Initial as needed.

func (Theme) Filter

func (t Theme) Filter() filter.Options

Filter returns filter.Options pre-filled with theme colors — prompt in KeyFG, text in BarFG, placeholder in Subtle, cursor in Accent, border colors matching pane. Set Width and override anything else on the returned value before passing to filter.New.

func (Theme) Form

func (t Theme) Form() form.Options

Form returns form.Options pre-filled with theme colors. Set Width, Height, Fields, and any SubmitText on the returned value before passing to form.New (or chain `.With(fields)`). Override individual Styles fields only if you need to deviate from the palette.

func (Theme) Help

func (t Theme) Help() help.Options

Help returns help.Options whose KeyStyle and DescStyle carry the same Background as the bar, so help.ShortView() drops into Statusbar.Left with no banding. Override ShortSeparator, ColumnSpacer, Width/Height, or the styles as needed.

func (Theme) Input

func (t Theme) Input() input.Options

Input returns input.Options pre-filled from the theme — text in BarFG, placeholder in Subtle, cursor in Accent, border colors matching pane. Set Width, Title (the field's label), and any placeholder before passing to input.New.

func (Theme) Inspector

func (t Theme) Inspector() inspector.Options

Inspector returns inspector.Options pre-filled with theme colors. Set Title, Fields, Filterable, and InitialDepth on the returned value.

func (Theme) List

func (t Theme) List() list.Options

List returns list.Options pre-filled from the theme, including nested Filter options (used only if Filterable=true). HScrollbar is enabled by default so long item labels stay readable via ←/→ / h/l. Set Width, Height, Title, Items, Filterable, and any placeholder via Filter.Placeholder.

func (Theme) Logview

func (t Theme) Logview() logview.Options

Logview returns logview.Options pre-filled from the theme — match highlight in Accent (bold + reverse), border colors matching pane, and the embedded filter using theme.Filter(). Set Width, Height, Title, Searchable, MaxLines, and any Filter.Placeholder before passing to logview.New.

func (Theme) Pane

func (t Theme) Pane() pane.Options

Pane returns pane.Options with only the color tokens applied. Border shape, title, title position, and slot brackets stay the caller's call. Includes a SpinnerStyle so panes set into a loading state render the spinner in the theme's accent color.

func (Theme) Statusbar

func (t Theme) Statusbar(left, right string) statusbar.Options

Statusbar returns statusbar.Options pre-filled from the theme, with Left and Right passed through so you don't have to set them separately.

func (Theme) Table

func (t Theme) Table() table.Options

Table returns table.Options pre-filled from the theme — header bold + Current fg, selected row bold + Accent fg + Subtle bg, border colors matching pane, HScrollbar enabled (wide tables are common), spinner in Accent, and the embedded filter using theme.Filter(). Set Width, Height, Title, Columns, Rows, Filterable, and any Filter.Placeholder before passing to table.New.

func (Theme) TextView

func (t Theme) TextView() textview.Options

TextView returns textview.Options pre-filled from the theme — match highlight in Accent (bold + reverse), current-line background in Subtle, border colors matching pane, and the embedded filter using theme.Filter(). Set Width, Height, Title, Content, Wrap, and Searchable on the returned value before passing to textview.New.

func (Theme) Toggle

func (t Theme) Toggle() toggle.Options

Toggle returns toggle.Options pre-filled from the theme — selected side in Accent (bold), unselected in Muted, border colors matching pane. Set Width, Title (the field's question), and Initial as needed.

func (Theme) Tree

func (t Theme) Tree() tree.Options

Tree returns tree.Options pre-filled from the theme — match highlight in Accent (bold + reverse), current-line background in Subtle, border colors matching pane, and the embedded filter using theme.Filter(). Set Width, Height, Title, Root, Searchable, and InitialDepth before passing to tree.New.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL