Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

Theming

Marcus Olsson edited this page Nov 5, 2017 · 1 revision

Style

A style specifies the appearance of a widget. More complex widgets allow you to set multiple styles for different aspects, e.g., Button may have one style for its normal state and another for when it's focused.

Selectors

A selector is a string of dot(.)-separated sections, to which you can attach a Style.

  • The first section should be the name of the widget.
  • If a section specifies a state, it should be in the form of "This widget is state", e.g., focused, selected.

Example: list.item.selected lets you specify the style for a selected item within a list.

Theme

An application may specify a theme, which is a complete specification of the styles used throughout the application.

theme := tui.NewTheme()
theme.SetStyle("list.item.selected", tui.Style{Fg: tui.ColorWhite, Bg: tui.ColorBlue})

ui.SetTheme(theme)

Design considerations

By default, applications should be monochrome. This is usually accomplished by simply not adding it to the DefaultTheme. However, widgets that can be selected or focused needs to be defined with Reverse: true.

Ideas

Loading theme from file

When using window managers like i3 or dwm I want my applications to follow the same color scheme. By introducing a configuration file that is shared across application written using tui they will get a consistent look.

Clone this wiki locally