styles

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: MIT Imports: 6 Imported by: ? modules, 0 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 styles holds the kontrolplane palette as it applies to the terminal.

The values come from the brand tokens (github.com/kontrolplane/assets, tokens/color.json and tokens/semantic.json). Terminals cannot blend alpha, so every rule and tint is the solid mix the token describes. A detected theme keeps the terminal's own background; both themes paint cornsilk and black forest text with olive accents on top of it. A theme chosen with --theme paints its own background as well (see Paint).

Index

Constants

This section is empty.

Variables

View Source
var Dark = Palette{
	Dark:      true,
	Base:      lipgloss.Color("#1A1A1A"),
	Surface:   lipgloss.Color("#353532"),
	Selection: lipgloss.Color("#3A3F28"),
	Rule:      lipgloss.Color("#3E3E3A"),
	RuleBold:  lipgloss.Color("#716F65"),
	Text:      cornsilk,
	Body:      lipgloss.Color("#ECE8D0"),
	Muted:     lipgloss.Color("#C3C0AD"),
	Faint:     lipgloss.Color("#979587"),
	Accent:    lipgloss.Color("#9FA57B"),
	Warm:      lipgloss.Color("#D0975D"),
	Success:   lipgloss.Color("#00C389"),
	Warning:   lipgloss.Color("#F7AB1B"),
	Info:      lipgloss.Color("#53A2FF"),
	Danger:    lipgloss.Color("#FF6467"),
}

Dark sits on the terminal's own dark ground. Tints mix cornsilk into a neutral dark so only the accent reads as olive.

View Source
var Light = Palette{
	Dark:      false,
	Base:      cornsilk,
	Surface:   lipgloss.Color("#F3F0D6"),
	Selection: lipgloss.Color("#D7D7BC"),
	Rule:      lipgloss.Color("#D3D3B8"),
	RuleBold:  lipgloss.Color("#BEBFA4"),
	Text:      blackForest,
	Body:      lipgloss.Color("#3D4A2C"),
	Muted:     lipgloss.Color("#60694C"),
	Faint:     lipgloss.Color("#6C7558"),
	Accent:    lipgloss.Color("#606C38"),
	Warm:      lipgloss.Color("#A16223"),
	Success:   lipgloss.Color("#007E4E"),
	Warning:   lipgloss.Color("#9C6000"),
	Info:      lipgloss.Color("#0067C7"),
	Danger:    lipgloss.Color("#E7000B"),
}

Light is the cornsilk stock. Hierarchy is a tint of black forest, never a grey.

View Source
var P = Dark

P is the active palette.

View Source
var Paint bool

Paint is set when the theme was chosen rather than detected. The palette then paints its own ground, since the terminal's may be the opposite of what the theme was made for.

Functions

func Accent

func Accent(s string) string

func Body

func Body(s string) string

func Bold

func Bold(s string) string

func Button

func Button(label string, focused bool, tone Tone) string

Button renders a dialog button. A focused button takes the primary treatment, or the given tone when the action it confirms is destructive.

func Clean

func Clean(s string) string

Clean makes text from the server safe to draw: control characters (C0, DEL, C1) are shown escaped.

func CleanBlock

func CleanBlock(s string) string

CleanBlock is Clean for multi-line text, keeping newlines; tabs become 4 spaces.

func Faint

func Faint(s string) string

func Fg

func Fg(t Tone) lipgloss.Style

Fg returns a style painting the given tone.

func Key

func Key(k, desc string) string

Key renders a key binding hint.

func Muted

func Muted(s string) string

func Render

func Render(spans ...Span) string

Render joins spans on the terminal's ground.

func SectionHeader

func SectionHeader(title string, width int, focused bool) string

SectionHeader renders a lowercase label followed by a hairline, filling width.

func SectionHeaderWith

func SectionHeaderWith(title, meta string, width int) string

SectionHeaderWith renders a section header with meta text right aligned in the rule.

func TextInput

func TextInput() textinput.Styles

TextInput returns the styles for single line inputs.

func Use

func Use(dark bool)

Use selects the dark or the light theme.

Types

type Palette

type Palette struct {
	Dark bool

	Base      color.Color // the plate or the stock
	Surface   color.Color // raised surfaces, unfocused buttons
	Selection color.Color // the row under the cursor
	Rule      color.Color // hairlines and borders
	RuleBold  color.Color // a rule that has to read as a division

	Text  color.Color // headings and anything that carries the page
	Body  color.Color // values and body copy
	Muted color.Color // labels and meta
	Faint color.Color // hints, punctuation, empty values

	Accent color.Color // olive: the brand's highlight, wildcards and indices
	Warm   color.Color // copper: numbers in payloads

	Success color.Color
	Warning color.Color
	Info    color.Color
	Danger  color.Color
}

Palette is one theme of the brand, resolved to solid colours.

func (Palette) Color

func (p Palette) Color(t Tone) color.Color

type Span

type Span struct {
	Text string
	Tone Tone
	Bold bool
}

Span is a run of text with a single tone. Cells and inline values are built from spans so they can be repainted onto a selected row without the inner resets cutting through its background.

func B

func B(text string, tone Tone) Span

func Bar

func Bar(ratio float64, width int, tone Tone) []Span

Bar renders a horizontal meter of the given width, filled to ratio.

func S

func S(text string, tone Tone) Span

func (Span) On

func (s Span) On(bg color.Color) string

func (Span) Style

func (s Span) Style() lipgloss.Style

type Tone

type Tone int

Tone names a foreground role, so text can be described once and painted on any ground.

const (
	ToneText Tone = iota
	ToneBody
	ToneMuted
	ToneFaint
	ToneAccent
	ToneWarm
	ToneSuccess
	ToneWarning
	ToneInfo
	ToneDanger
	ToneRule
)

Jump to

Keyboard shortcuts

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