style

package
v0.267.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package style centralizes the lipgloss palette and reusable styles. All values are derived from the active theme.Theme and can be swapped at runtime via Apply — this is what powers live theme switching in the TUI. Existing callers reference the package-level vars directly; Apply reassigns them.

Index

Constants

View Source
const (
	IconCheck    = "✓"
	IconCross    = "✗"
	IconBullet   = "•"
	IconArrow    = "→"
	IconCaret    = "❯"
	IconDot      = "●"
	IconCircle   = "○"
	IconStore    = "▣"
	IconModel    = "◈"
	IconTuple    = "≡"
	IconChange   = "⇅"
	IconQuery    = "?"
	IconAssert   = "✦"
	IconGear     = "✱"
	IconSpark    = "✦"
	EdgeDirect   = "←"
	EdgeComputed = "="
	EdgeTTU      = "⇡"
)

Icons used across the CLI and TUI (Crush-inspired).

Variables

View Source
var (
	Primary     color.Color
	Secondary   color.Color
	Accent      color.Color
	Keyword     color.Color
	Violet      color.Color // second accent: mode chips, dialog borders/titles
	Magenta     color.Color // second accent: selection + palette highlights
	Fg          color.Color
	Muted       color.Color
	Faintc      color.Color
	BgBase      color.Color
	BgPanel     color.Color // sidebar column
	BgRaised    color.Color // main pane, cards (old BgPanel call sites move here)
	BgHighlight color.Color // chips, badges, keycaps
	BgOverlay   color.Color // dialog scrim/shadow
	Subtle      color.Color
	Green       color.Color
	Amber       color.Color
	Red         color.Color
	Info        color.Color
	OnAccent    color.Color

	// Back-compat aliases kept for existing call sites.
	Indigo color.Color // == Secondary
	Pink   color.Color // == Keyword
	Cyan   color.Color // == Accent
)

Colors (reassigned by Apply).

View Source
var (
	Title    lipgloss.Style
	Heading  lipgloss.Style
	Subtitle lipgloss.Style
	Key      lipgloss.Style
	Value    lipgloss.Style
	Faint    lipgloss.Style
	Bold     lipgloss.Style
	Success  lipgloss.Style
	Failure  lipgloss.Style
	Warn     lipgloss.Style

	AllowedBadge lipgloss.Style
	DeniedBadge  lipgloss.Style
	TableHeader  lipgloss.Style
	Panel        lipgloss.Style
	ActivePanel  lipgloss.Style
)

Styles (reassigned by Apply).

View Source
var Active = theme.Default()

Active is the currently applied theme.

Functions

func Allowed

func Allowed(ok bool) string

Allowed returns a styled ALLOWED/DENIED badge for a boolean outcome.

func Apply

func Apply(t theme.Theme)

Apply rebuilds every color and style from the given theme.

func Blend

func Blend(a, b color.Color, k float64) color.Color

Blend returns the color k of the way (in Lab space) from a to b. k=0 is a, k=1 is b. Falls back to a when either color can't be converted, or under the mono theme (no color blending).

func Bullet

func Bullet() string

Bullet returns a primary-colored bullet prefix.

func Chip

func Chip(text string, fg, bg color.Color) string

Chip renders a small filled label: bold fg on bg with 1-col padding.

func Dot

func Dot(state DotState) string

Dot returns a colored ● for the given state.

func FieldHighlight

func FieldHighlight() color.Color

FieldHighlight is the background that marks the focused form field's row: the base surface lifted toward the primary accent so the active field reads as "here" without falling back on a neutral gray.

func Gradient

func Gradient(s string) string

Gradient renders s with a per-rune color blend between the active theme's GradStartHex and GradEndHex (Lab space). Under the mono theme it returns the text unstyled; when the theme defines no gradient it falls back to a solid bold Primary.

func GradientBlock

func GradientBlock(s string) string

GradientBlock applies the brand gradient diagonally across multi-line block art (e.g. a wordmark): color advances with column + row so it flows from the top-left start color to the bottom-right end color. Mono/no-gradient themes fall back to solid bold Primary.

func GradientBlockPhase

func GradientBlockPhase(s string, phase float64) string

GradientBlockPhase renders block art like GradientBlock with the ramp position shifted by a drift phase. Phase 0 is byte-identical to GradientBlock. Mono/no-gradient themes fall back identically.

func GradientPill

func GradientPill(text string) string

GradientPill renders text on a per-rune brand-gradient background with OnAccent foreground — the active-nav treatment. Mono themes fall back to a plain Primary chip.

func GradientPillPhase

func GradientPillPhase(text string, phase float64) string

GradientPillPhase is GradientPill with a drift phase; phase 0 matches GradientPill exactly.

func Keycap

func Keycap(k string) string

Keycap renders a dim key hint pill (e.g. "q", "↵") on the raised surface.

func PercentColor added in v0.266.0

func PercentColor(pct float64) lipgloss.Style

PercentColor picks the coverage-percentage style by threshold: full coverage reads success/green, zero reads failure/red, and any partial amount in between reads warn/amber (the closest existing primitive to a dedicated "attention" color).

func SanitizeTerminal

func SanitizeTerminal(s string) string

SanitizeTerminal removes escape sequences, control characters and text-direction spoofing characters from untrusted text before it is styled for an interactive terminal.

func SanitizeTerminalKeepSGR added in v0.267.0

func SanitizeTerminalKeepSGR(s string) string

SanitizeTerminalKeepSGR removes everything SanitizeTerminal does *except* SGR sequences (CSI … m), which only choose colors and weights.

It exists for lines the CLI composes itself and deliberately styles — the success/info/warning printers are handed values already wrapped in style.Bold.Render — where stripping every escape would silently discard that styling. Sequences that can act rather than merely paint (OSC clipboard and title writes, cursor movement, screen clears), raw control characters and bidi overrides are still removed, so a hostile value interpolated into such a line cannot do anything beyond changing its own colour.

Use SanitizeTerminal for text that arrives from the server or a file, where no styling is expected in the first place.

func SectionHeader

func SectionHeader(title string, width int) string

SectionHeader renders a crush-style section header: a mid-tone bold title followed by a faint hairline rule filling the remaining width. This is the flat UI's structural primitive — panels are delimited by headers and whitespace, not borders.

func SectionHeaderFocused

func SectionHeaderFocused(title string, width int) string

SectionHeaderFocused renders the header with both the title and rule in the Primary accent, marking the main panel as the focused region.

func SectionHeaderTinted

func SectionHeaderTinted(title string, width int, tint color.Color) string

SectionHeaderTinted is SectionHeader with an explicit rule color, used for the one-frame verdict flash on the query Result header.

func SetTheme

func SetTheme(name string) bool

SetTheme applies a theme by name; returns false if unknown.

Types

type DotState

type DotState int

DotState selects the color of a status dot.

const (
	DotOnline  DotState = iota // mint
	DotBusy                    // amber
	DotError                   // coral
	DotOffline                 // faint
)

Jump to

Keyboard shortcuts

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