ui

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package ui provides styled CLI output components using lipgloss

Index

Constants

This section is empty.

Variables

View Source
var (
	// Primary colors
	PrimaryColor   = lipgloss.Color("#7C3AED") // Purple
	SecondaryColor = lipgloss.Color("#3B82F6") // Blue

	// Status colors
	SuccessColor = lipgloss.Color("#10B981") // Green
	ErrorColor   = lipgloss.Color("#EF4444") // Red
	WarningColor = lipgloss.Color("#F59E0B") // Yellow/Amber
	InfoColor    = lipgloss.Color("#6B7280") // Gray

	// UI colors
	BorderColor   = lipgloss.Color("#374151") // Dark gray
	HeaderBgColor = lipgloss.Color("#1F2937") // Darker gray
	AltRowColor   = lipgloss.Color("#1A1A2E") // Alternate row background
)

Color palette

View Source
var (
	// TitleStyle for main titles
	TitleStyle = lipgloss.NewStyle().
				Bold(true).
				Foreground(PrimaryColor).
				MarginBottom(1).
				Padding(0, 1)

	// HeaderStyle for table headers
	HeaderStyle = lipgloss.NewStyle().
				Bold(true).
				Foreground(lipgloss.Color("#FFFFFF")).
				Background(HeaderBgColor).
				Padding(0, 1)

	// RowStyle for table rows
	RowStyle = lipgloss.NewStyle().
				Padding(0, 1)

	// AltRowStyle for alternating table rows
	AltRowStyle = lipgloss.NewStyle().
				Background(AltRowColor).
				Padding(0, 1)

	// SelectedStyle for selected items
	SelectedStyle = lipgloss.NewStyle().
					Background(lipgloss.Color("#374151")).
					Foreground(lipgloss.Color("#FFFFFF"))

	// CardStyle for card-like containers
	CardStyle = lipgloss.NewStyle().
				Border(lipgloss.RoundedBorder()).
				BorderForeground(BorderColor).
				Padding(1, 2).
				Margin(1, 0)
)

Base styles

View Source
var (
	// SuccessStyle for success messages
	SuccessStyle = lipgloss.NewStyle().
					Foreground(SuccessColor).
					Bold(true)

	// ErrorStyle for error messages
	ErrorStyle = lipgloss.NewStyle().
				Foreground(ErrorColor).
				Bold(true)

	// WarningStyle for warning messages
	WarningStyle = lipgloss.NewStyle().
					Foreground(WarningColor)

	// InfoStyle for informational messages
	InfoStyle = lipgloss.NewStyle().
				Foreground(InfoColor)

	// EnabledStyle for enabled status
	EnabledStyle = SuccessStyle

	// DisabledStyle for disabled status
	DisabledStyle = lipgloss.NewStyle().
					Foreground(InfoColor)
)

Status styles

View Source
var (
	// LabelStyle for field labels
	LabelStyle = lipgloss.NewStyle().
				Foreground(lipgloss.Color("#9CA3AF")).
				Bold(true)

	// ValueStyle for field values
	ValueStyle = lipgloss.NewStyle().
				Foreground(lipgloss.Color("#E5E7EB"))
)

Label and value styles

View Source
var (
	StatusEnabled       = SuccessStyle.Render("✅ 已启用")
	StatusDisabled      = DisabledStyle.Render("❌ 未启用")
	StatusConnected     = SuccessStyle.Render("✅ 已连接")
	StatusNotConfigured = DisabledStyle.Render("❌ 未配置")
	StatusExpired       = WarningStyle.Render("⚠️ 已过期")
)

Status text helpers

View Source
var (
	ThemePurple  = lipgloss.Color("#7C3AED")
	ThemeGreen   = lipgloss.Color("#22C55E")
	ThemeOrange  = lipgloss.Color("#F59E0B")
	ThemeRed     = lipgloss.Color("#EF4444")
	ThemeGray    = lipgloss.Color("#94A3B8")
	ThemeBgDark  = lipgloss.Color("#1E1E2E")
	ThemeBgCard  = lipgloss.Color("#2D2D3F")
	ThemeText    = lipgloss.Color("#E2E8F0")
	ThemeDimText = lipgloss.Color("#64748B")
)

Theme colors (Claude Code inspired)

Functions

func Bold

func Bold(text string) string

Bold returns bold text

func Card

func Card(title string, content []string) string

Card creates a card-style container for displaying information

func CheckList

func CheckList(items []CheckItem) string

CheckList creates a checklist with check/cross marks

func Dim

func Dim(text string) string

Dim returns dimmed text

func DimStyle added in v1.0.4

func DimStyle() lipgloss.Style

DimStyle returns a style for secondary/dimmed text.

func Divider

func Divider() string

Divider creates a horizontal divider

func Error

func Error(msg string) string

Error prints an error message

func Header(text string) string

Header creates a styled header

func Highlight

func Highlight(text string) string

Highlight returns highlighted text

func Info

func Info(msg string) string

Info prints an informational message

func KeyValue

func KeyValue(items [][2]string, keyWidth int) string

KeyValue creates aligned key-value pairs

func KeyValueCard

func KeyValueCard(title string, pairs map[string]string) string

KeyValueCard creates a card with key-value pairs

func LabelValue

func LabelValue(label, value string) string

LabelValue formats a label-value pair

func List

func List(items []string) string

List creates a bulleted list

func PadCenter

func PadCenter(s string, width int) string

PadCenter centers a string within a given display width

func PadLeft

func PadLeft(s string, width int) string

PadLeft pads a string on the left to a given display width

func PadRight

func PadRight(s string, width int) string

PadRight pads a string on the right to a given display width

func PriorityStyle added in v1.0.4

func PriorityStyle(priority int) lipgloss.Style

PriorityStyle returns a bold style colored by priority level.

func ProgressBar added in v1.0.4

func ProgressBar(width int, progress int) string

ProgressBar renders a gradient progress bar with the given width and progress (0-100).

func ProviderCard

func ProviderCard(name, displayName, description, authType, status string, capabilities []CheckItem) string

ProviderCard creates a styled provider information card

func QuadrantStyle added in v1.0.4

func QuadrantStyle(quadrant int) lipgloss.Style

QuadrantStyle returns a background-colored style for Eisenhower matrix quadrants.

func Section

func Section(header string, content string) string

Section creates a section with a header

func StatusBadge

func StatusBadge(status string) string

StatusBadge creates a colored status badge

func StatusBarStyle added in v1.0.4

func StatusBarStyle() lipgloss.Style

StatusBarStyle returns a style for the TUI bottom status bar.

func StringWidth

func StringWidth(s string) int

StringWidth calculates the display width of a string (supporting CJK characters)

func Success

func Success(msg string) string

Success prints a success message

func TaskCard added in v1.0.4

func TaskCard(status string) lipgloss.Style

TaskCard returns a card style with a colored left border based on task status.

func ThemeTitleStyle added in v1.0.4

func ThemeTitleStyle() lipgloss.Style

ThemeTitleStyle returns a style for TUI headers.

func Warning

func Warning(msg string) string

Warning prints a warning message

Types

type CheckItem

type CheckItem struct {
	Text    string
	Checked bool
}

CheckItem represents a checklist item

type Column

type Column struct {
	Header     string
	Width      int
	AlignLeft  bool
	AlignRight bool
}

Column defines a table column

type SimpleTable

type SimpleTable struct {
	// contains filtered or unexported fields
}

SimpleTable creates a simple aligned table without borders

func NewSimpleTable

func NewSimpleTable(columns ...Column) *SimpleTable

NewSimpleTable creates a simple table

func (*SimpleTable) AddRow

func (t *SimpleTable) AddRow(cells ...string) *SimpleTable

AddRow adds a row to the simple table

func (*SimpleTable) HideHeader

func (t *SimpleTable) HideHeader() *SimpleTable

HideHeader hides the table header

func (*SimpleTable) Render

func (t *SimpleTable) Render() string

Render renders the simple table

type Table

type Table struct {
	// contains filtered or unexported fields
}

Table represents a styled table

func NewTable

func NewTable(headers ...string) *Table

NewTable creates a new table with headers

func (*Table) AddRow

func (t *Table) AddRow(cells ...string) *Table

AddRow adds a row to the table

func (*Table) Render

func (t *Table) Render() string

Render renders the table to a string

func (*Table) SetWidth

func (t *Table) SetWidth(width int) *Table

SetWidth sets the table width

func (*Table) String

func (t *Table) String() string

String implements Stringer interface

Jump to

Keyboard shortcuts

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