tui

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Primary Colors
	ColorAccent    = "#00D9FF" // Bright cyan for primary actions
	ColorPrimary   = "#874BFD" // Purple for highlights
	ColorSecondary = "#FF6B6B" // Coral for emphasis

	// UI Colors
	ColorSuccess = "#10B981" // Green for success
	ColorWarning = "#F59E0B" // Amber for warnings
	ColorError   = "#EF4444" // Red for errors
	ColorInfo    = "#3B82F6" // Blue for information

	// Neutral Colors
	ColorText     = "#E4E4E7" // Light gray for primary text
	ColorTextDim  = "#71717A" // Dimmed text
	ColorBorder   = "#3F3F46" // Border color
	ColorBg       = "#18181B" // Background
	ColorBgSubtle = "#27272A" // Subtle background
)

Color Palette - Using a modern, cohesive color scheme

View Source
const (
	IconCheck      = "✓"
	IconCross      = "✗"
	IconInfo       = "ℹ"
	IconWarning    = "⚠"
	IconArrowRight = "→"
	IconArrowLeft  = "←"
	IconBullet     = "•"
	IconDot        = "·"

	// Selection indicators
	RadioEmpty      = "○"
	RadioFilled     = "●"
	CheckboxEmpty   = "☐"
	CheckboxFilled  = "☑"
	CheckboxPartial = "☒"

	// Cursor indicators
	CursorArrow = "▶"
	CursorBlock = "█"
	CursorLine  = "│"
)

Icons and symbols used consistently across components

Variables

View Source
var (
	// Title Styles - For section headers
	TitleStyle = lipgloss.NewStyle().
				Foreground(lipgloss.Color(ColorAccent)).
				Bold(true).
				MarginBottom(1)

	// Subtitle style for secondary headers
	SubtitleStyle = lipgloss.NewStyle().
					Foreground(lipgloss.Color(ColorText)).
					Italic(true)

	// Step indicator style (e.g., "Step 1/2")
	StepStyle = lipgloss.NewStyle().
				Foreground(lipgloss.Color(ColorPrimary)).
				Background(lipgloss.Color(ColorBgSubtle)).
				Padding(0, 2).
				Bold(true).
				MarginBottom(1)

	// Focus indicator styles
	FocusedStyle = lipgloss.NewStyle().
					Foreground(lipgloss.Color(ColorAccent)).
					Bold(true)

	UnfocusedStyle = lipgloss.NewStyle().
					Foreground(lipgloss.Color(ColorTextDim))

	// Selection styles - Consistent across all components
	SelectedStyle = lipgloss.NewStyle().
					Foreground(lipgloss.Color(ColorAccent)).
					Bold(true)

	UnselectedStyle = lipgloss.NewStyle().
					Foreground(lipgloss.Color(ColorText))

	// Item container styles
	ItemStyle = lipgloss.NewStyle().
				PaddingLeft(2)

	FocusedItemStyle = lipgloss.NewStyle().
						BorderStyle(lipgloss.NormalBorder()).
						BorderLeft(true).
						BorderForeground(lipgloss.Color(ColorAccent)).
						PaddingLeft(1)

	// Description styles
	DescriptionStyle = lipgloss.NewStyle().
						Foreground(lipgloss.Color(ColorTextDim)).
						Italic(true).
						PaddingLeft(4)

	// Status indicator styles
	SuccessStyle = lipgloss.NewStyle().
					Foreground(lipgloss.Color(ColorSuccess)).
					Bold(true)

	ErrorStyle = lipgloss.NewStyle().
				Foreground(lipgloss.Color(ColorError)).
				Bold(true)

	WarningStyle = lipgloss.NewStyle().
					Foreground(lipgloss.Color(ColorWarning)).
					Bold(true)

	InfoStyle = lipgloss.NewStyle().
				Foreground(lipgloss.Color(ColorInfo))

	// Help text style
	HelpStyle = lipgloss.NewStyle().
				Foreground(lipgloss.Color(ColorTextDim)).
				MarginTop(1)

	// Disabled style
	DisabledStyle = lipgloss.NewStyle().
					Foreground(lipgloss.Color("#3F3F46")).
					Strikethrough(true)

	// Checkbox specific styles
	CheckedStyle = lipgloss.NewStyle().
					Foreground(lipgloss.Color(ColorSuccess))

	UncheckedStyle = lipgloss.NewStyle().
					Foreground(lipgloss.Color(ColorTextDim))

	// Radio button specific styles
	RadioSelectedStyle = lipgloss.NewStyle().
						Foreground(lipgloss.Color(ColorPrimary))

	RadioUnselectedStyle = lipgloss.NewStyle().
							Foreground(lipgloss.Color(ColorTextDim))

	// Box/Container styles
	BoxStyle = lipgloss.NewStyle().
				BorderStyle(lipgloss.RoundedBorder()).
				BorderForeground(lipgloss.Color(ColorBorder)).
				Padding(1, 2)

	// Progress indicator
	ProgressStyle = lipgloss.NewStyle().
					Foreground(lipgloss.Color(ColorPrimary))

	// Prompt styles
	PromptStyle = lipgloss.NewStyle().
				Foreground(lipgloss.Color(ColorPrimary)).
				Bold(true)

	// Input field style
	InputStyle = lipgloss.NewStyle().
				BorderStyle(lipgloss.RoundedBorder()).
				BorderForeground(lipgloss.Color(ColorBorder)).
				Padding(0, 1)

	FocusedInputStyle = lipgloss.NewStyle().
						BorderStyle(lipgloss.RoundedBorder()).
						BorderForeground(lipgloss.Color(ColorAccent)).
						Padding(0, 1)

	// Badge styles for status tags
	BadgeStyle = lipgloss.NewStyle().
				Background(lipgloss.Color(ColorBgSubtle)).
				Foreground(lipgloss.Color(ColorText)).
				Padding(0, 1).
				MarginLeft(1)

	BadgeSuccessStyle = lipgloss.NewStyle().
						Background(lipgloss.Color(ColorSuccess)).
						Foreground(lipgloss.Color("#FFFFFF")).
						Padding(0, 1).
						MarginLeft(1)

	BadgeWarningStyle = lipgloss.NewStyle().
						Background(lipgloss.Color(ColorWarning)).
						Foreground(lipgloss.Color("#000000")).
						Padding(0, 1).
						MarginLeft(1)

	// Cursor and selection indicators
	CursorStyle = lipgloss.NewStyle().
				Foreground(lipgloss.Color(ColorAccent)).
				Bold(true)

	// List item styles (redefining for consistency)
	ListItemStyle = lipgloss.NewStyle().
					PaddingLeft(2)

	SelectedItemStyle = lipgloss.NewStyle().
						Foreground(lipgloss.Color(ColorAccent)).
						Bold(true).
						PaddingLeft(2)

	// Legacy style mappings for compatibility
	QuestionStyle = PromptStyle
	MutedStyle    = UnfocusedStyle
	BorderStyle   = BoxStyle
)

Unified Design System Styles

Functions

func CheckboxSelection

func CheckboxSelection(title string, options []CheckboxOption) ([]string, error)

CheckboxSelection displays a checkbox selection interface and returns selected values

func Confirm

func Confirm(question string) (bool, error)

Confirm asks the user a yes/no question

func ListSelection

func ListSelection(title string, items []list.Item) (list.Item, error)

ListSelection runs a list selection and returns the selected item

func NewCheckboxModel

func NewCheckboxModel(title string, options []CheckboxOption) checkboxModel

NewCheckboxModel creates a new checkbox selection model

func NewListModel

func NewListModel(title string, items []list.Item) listModel

NewListModel creates a new list selection model

func Prompt

func Prompt(question string) (string, error)

Prompt asks the user a question and returns their answer

func RadioSelection added in v0.1.1

func RadioSelection(title string, options []RadioOption, defaultSelection int) (string, error)

RadioSelection displays a radio button selection interface and returns the selected value

func ReadMultilineInput

func ReadMultilineInput() (string, error)

ReadMultilineInput reads multi-line input until Ctrl+D

func RenderBadge added in v0.1.1

func RenderBadge(text string, style lipgloss.Style) string

RenderBadge renders a status badge

func RenderCheckbox

func RenderCheckbox(checked bool, label string, focused bool) string

RenderCheckbox renders a checkbox with consistent styling

func RenderCheckboxLegacy added in v0.1.1

func RenderCheckboxLegacy(checked bool, label string) string

Legacy compatibility functions

func RenderHelp added in v0.1.1

func RenderHelp(keys ...string) string

RenderHelp renders help text with consistent formatting

func RenderProgress

func RenderProgress(current, total int, label string) string

RenderProgress renders a progress indicator

func RenderRadio added in v0.1.1

func RenderRadio(selected bool, label string, focused bool) string

RenderRadio renders a radio button with consistent styling

func RenderStep added in v0.1.1

func RenderStep(current, total int, label string) string

RenderStep renders a step indicator (e.g., "Step 1 of 2")

Types

type CheckboxOption

type CheckboxOption struct {
	Label       string
	Description string
	Value       string
	Checked     bool
}

CheckboxOption represents a single checkbox option

type RadioOption added in v0.1.1

type RadioOption struct {
	Label       string
	Description string
	Value       string
	Disabled    bool
}

RadioOption represents a single radio button option

Jump to

Keyboard shortcuts

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