theme

package
v0.42.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 28 Imported by: 2 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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.New(palette.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

Theme fills in the chrome tokens — colors, and the surface's border shape and slot brackets — so every component drawn from one palette agrees. Anything you need to override for a single component (a custom width, a deliberately heavier border on one pane) you set on the returned Options before passing it to that component's New; a per-instance value always wins over the theme.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Theme

type Theme struct {
	palette.Palette

	// Glyphs are the marks components draw — row cursors, expand arrows,
	// scrollbar thumbs, sort indicators. Empty fields fall back to
	// glyph.Default, so setting one arrow does not blank the rest.
	Glyphs glyph.Set

	// Surface is how components' edges and bodies are drawn, resolved
	// against this theme's palette and the terminal. The builders hand each
	// component the form it needs — the surface itself, its overlay form for
	// modals, its field form for single-line inputs.
	Surface surface.Resolved
}

Theme is what components are built from: a palette, drawn with a surface, using a set of glyphs. Nobody picks a theme directly — the user picks a palette and a surface, and the app shell composes them (Compose) and hands the result to every screen's SetTheme.

The palette's colours are promoted, so t.Accent and t.BorderActive read as they always did.

func Compose added in v0.39.0

func Compose(p palette.Palette, s surface.Surface, caps surface.Caps) Theme

Compose builds the theme for one palette drawn with one surface, on a terminal offering caps. The shell calls it whenever the user changes either axis.

func New added in v0.39.0

func New(p palette.Palette) Theme

New is p drawn Outlined: the look of an app that never chose a surface.

func (Theme) Actions added in v0.21.0

func (t Theme) Actions() action.Options

Actions returns action.Options pre-filled from the theme — the label in BarFG, the gloss and the key column in Muted, the cursor row bold in Accent, and disabled rows in Subtle so an unavailable verb reads as present but out of reach rather than as ordinary text. Group headers are bold in Current, the table header's colour. Set Title and Set before passing to action.New.

Unlike pkg/output, this follows rule 3's th.Component() convention: a Menu is a plain component rather than a screen.Screen, so pkg/action never imports pkg/screen and there is no import cycle to invert.

func (Theme) Activity added in v0.27.0

func (t Theme) Activity() activity.Options

Activity returns activity.Options pre-filled from the theme — the spinner and its label in Accent.

Nested into List() and Tree(), which render their own rows and can use lipgloss freely. pkg/table needs the cell-safe form instead; see activityCell.

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) Eventlog added in v0.31.0

func (t Theme) Eventlog() eventlog.Options

Eventlog returns eventlog.Options pre-filled from the theme — the selected item in Accent on Subtle like a table row, match highlight like the logview's, border colors matching pane. Set Title, Anchored, Filterable and Searchable on the returned value before eventlog.New.

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 or the styles as needed.

func (Theme) HelpOverlay added in v0.25.0

func (t Theme) HelpOverlay() help.OverlayOptions

HelpOverlay returns help.OverlayOptions pre-filled from the theme — the key column in KeyFG, descriptions in BarFG, section headings bold in Accent, and the overlay border shape the other modals use. Set Title and Searchable before passing to help.NewOverlay.

The styles carry no Background: unlike Help(), which is embedded in the statusbar and has to match its band, the overlay draws on the pane's own ground.

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) Menu added in v0.40.0

func (t Theme) Menu() menu.Options

Menu returns menu.Options pre-filled from the theme — labels in the body's own colour, descriptions dimmed in Muted, group headers bold in Current (as the action menu draws them), the cursor row bold in Accent, border colours matching pane, and the embedded filter using theme.Filter(). Set Title, Items and Filterable before passing to menu.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) Resolve added in v0.39.0

func (t Theme) Resolve(s surface.Surface) surface.Resolved

Resolve resolves s against this theme's palette and terminal — how a screen pins one component to a surface other than the app's:

opts := t.Logview()
opts.Surface = t.Resolve(surface.Outlined)

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