ui

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// White
	ColorWhite = "#FFFFFF"

	// Gray scale
	ColorGray50  = "#FAFBFC"
	ColorGray100 = "#F5F7FA"
	ColorGray200 = "#E4E8ED"
	ColorGray300 = "#D1D6DE"
	ColorGray400 = "#9FA7B2"
	ColorGray500 = "#6C7585"
	ColorGray600 = "#4E5560"
	ColorGray700 = "#3C414C"
	ColorGray800 = "#212732"
	ColorGray900 = "#141921"
	ColorGray950 = "#0E1119"

	// Blue
	ColorBlue50  = "#EFF6FF"
	ColorBlue100 = "#DCEBFF"
	ColorBlue200 = "#C1DBFF"
	ColorBlue300 = "#97C1FF"
	ColorBlue400 = "#639CFF"
	ColorBlue500 = "#2E7BFF"
	ColorBlue600 = "#0D5DFF"
	ColorBlue700 = "#0847F7"
	ColorBlue800 = "#0036C9"
	ColorBlue900 = "#00299A"
	ColorBlue950 = "#001A62"

	// Green
	ColorGreen50  = "#F1FCF5"
	ColorGreen100 = "#DDF8E6"
	ColorGreen200 = "#B9F1CC"
	ColorGreen300 = "#95E5B0"
	ColorGreen400 = "#63D78E"
	ColorGreen500 = "#3CC274"
	ColorGreen600 = "#30A059"
	ColorGreen700 = "#267E46"
	ColorGreen800 = "#1E633A"
	ColorGreen900 = "#195232"
	ColorGreen950 = "#0B2D1B"

	// Red
	ColorRed50  = "#FEF2F2"
	ColorRed100 = "#FEE2E2"
	ColorRed200 = "#FECACA"
	ColorRed300 = "#FCA5A5"
	ColorRed400 = "#F87171"
	ColorRed500 = "#EF4444"
	ColorRed600 = "#DC2626"
	ColorRed700 = "#B91C1C"
	ColorRed800 = "#991B1B"
	ColorRed900 = "#7F1D1D"
	ColorRed950 = "#450A0A"

	// Orange
	ColorOrange50  = "#FEF5EF"
	ColorOrange100 = "#FCE9DA"
	ColorOrange200 = "#FAD3B6"
	ColorOrange300 = "#F6B484"
	ColorOrange400 = "#EF894F"
	ColorOrange500 = "#E86832"
	ColorOrange600 = "#DF4C1C"
	ColorOrange700 = "#B53C19"
	ColorOrange800 = "#913118"
	ColorOrange900 = "#7A2914"
	ColorOrange950 = "#3E130A"

	// Yellow
	ColorYellow50  = "#FFFBEB"
	ColorYellow100 = "#FEF3C7"
	ColorYellow200 = "#FDE68A"
	ColorYellow300 = "#F8D34C"
	ColorYellow400 = "#F9C424"
	ColorYellow500 = "#EAAE06"
	ColorYellow600 = "#CA8A04"
	ColorYellow700 = "#A16207"
	ColorYellow800 = "#854D0E"
	ColorYellow900 = "#713F12"
	ColorYellow950 = "#451A03"

	// Teal
	ColorTeal50  = "#EEFBF9"
	ColorTeal100 = "#DBF5F0"
	ColorTeal200 = "#BFEDE4"
	ColorTeal300 = "#A3E1D5"
	ColorTeal400 = "#80D0C3"
	ColorTeal500 = "#51B9A9"
	ColorTeal600 = "#2F9589"
	ColorTeal700 = "#237872"
	ColorTeal800 = "#1A635E"
	ColorTeal900 = "#124946"
	ColorTeal950 = "#0A2F2F"

	// Purple
	ColorPurple50  = "#F5F2FF"
	ColorPurple100 = "#EDE8FF"
	ColorPurple200 = "#DDD3FF"
	ColorPurple300 = "#C5B2FF"
	ColorPurple400 = "#A787FF"
	ColorPurple500 = "#8657FF"
	ColorPurple600 = "#6838E0"
	ColorPurple700 = "#4B19C1"
	ColorPurple800 = "#3F0DAB"
	ColorPurple900 = "#33068D"
	ColorPurple950 = "#1F005C"
)

Chainlink Blocks Color Palette Using high-contrast colors optimized for dark terminal backgrounds

Variables

View Source
var (
	// TitleStyle - for main headers (Blue 500 - bright and visible)
	TitleStyle = lipgloss.NewStyle().
				Bold(true).
				Foreground(lipgloss.Color(ColorBlue500))

	// SuccessStyle - for success messages (Green 400 - bright green)
	SuccessStyle = lipgloss.NewStyle().
					Bold(true).
					Foreground(lipgloss.Color(ColorGreen400))

	// ErrorStyle - for error messages (Red 400 - high contrast)
	ErrorStyle = lipgloss.NewStyle().
				Bold(true).
				Foreground(lipgloss.Color(ColorRed400))

	// WarningStyle - for warnings (Yellow 400 - bright yellow)
	WarningStyle = lipgloss.NewStyle().
					Bold(true).
					Foreground(lipgloss.Color(ColorYellow400))

	// BoxStyle - for bordered content boxes (Blue 500 border)
	BoxStyle = lipgloss.NewStyle().
				Border(lipgloss.RoundedBorder()).
				BorderForeground(lipgloss.Color(ColorBlue500)).
				Padding(0, 1)

	// DimStyle - for less important/secondary text (Gray 500)
	DimStyle = lipgloss.NewStyle().
				Foreground(lipgloss.Color(ColorGray500))

	// StepStyle - for step instructions (Blue 400 - lighter, visible)
	StepStyle = lipgloss.NewStyle().
				Foreground(lipgloss.Color(ColorBlue400))

	// BoldStyle - plain bold
	BoldStyle = lipgloss.NewStyle().
				Bold(true)

	// CodeStyle - for code/command snippets (Blue 300 - very visible)
	CodeStyle = lipgloss.NewStyle().
				Foreground(lipgloss.Color(ColorBlue300))

	// CommandStyle - for CLI commands (Blue 400 - prominent)
	CommandStyle = lipgloss.NewStyle().
					Bold(true).
					Foreground(lipgloss.Color(ColorBlue400))

	// AccentStyle - for highlighted/accent text (Purple 400)
	AccentStyle = lipgloss.NewStyle().
				Foreground(lipgloss.Color(ColorPurple400))

	// URLStyle - for links (Teal 400 - distinct, underlined)
	URLStyle = lipgloss.NewStyle().
				Underline(true).
				Foreground(lipgloss.Color(ColorTeal400))

	// HighlightStyle - for important highlights (Yellow 300)
	HighlightStyle = lipgloss.NewStyle().
					Bold(true).
					Foreground(lipgloss.Color(ColorYellow300))
)

Styles - using Chainlink Blocks palette with high contrast for terminal

Functions

func Bold

func Bold(text string)

Bold prints bold text

func Box

func Box(text string)

Box prints text in a bordered box (Chainlink Blue border)

func ChainlinkKeyMap

func ChainlinkKeyMap() *huh.KeyMap

ChainlinkKeyMap returns a custom keymap that uses Tab for autocomplete

func ChainlinkTheme

func ChainlinkTheme() *huh.Theme

ChainlinkTheme returns a Huh theme using Chainlink Blocks palette

func Code

func Code(text string)

Code prints text styled as code (Light Blue)

func Command

func Command(text string)

Command prints a CLI command (Bold Light Blue - prominent)

func Confirm

func Confirm(title string, opts ...ConfirmOption) (bool, error)

Confirm displays a yes/no confirmation prompt and returns the user's choice.

func Dim

func Dim(text string)

Dim prints dimmed/secondary text (Gray - less important)

func DownloadWithProgress

func DownloadWithProgress(resp io.ReadCloser, contentLength int64, destFile *os.File, message string) error

DownloadWithProgress downloads a file with a progress bar display. Returns the number of bytes downloaded and any error.

func Error

func Error(text string)

Error prints an error message to stderr (Orange - high contrast)

func ErrorWithHelp

func ErrorWithHelp(text, suggestion string)

ErrorWithHelp prints an error message with a helpful suggestion to stderr

func ErrorWithSuggestions

func ErrorWithSuggestions(text string, suggestions []string)

ErrorWithSuggestions prints an error message with multiple suggestions to stderr

func FormatBytes

func FormatBytes(bytes int64) string

FormatBytes formats bytes into human readable format

func Indent

func Indent(text string, level int) string

Indent returns text with indentation

func Input

func Input(title string, opts ...InputOption) (string, error)

Input displays a single text input prompt and returns the entered value.

func InputForm

func InputForm(fields []InputField) error

InputForm displays a multi-field input form. Each field writes to its Value pointer.

func Line

func Line()

Line prints an empty line

func Print

func Print(text string)

Print prints plain text (for gradual migration - can be replaced later)

func Printf

func Printf(format string, args ...interface{})

Printf prints formatted plain text

func ProgressBar

func ProgressBar(percent float64, width int) string

ProgressBar creates a simple styled progress bar string (for non-interactive use)

func RenderAccent

func RenderAccent(text string) string

func RenderBold

func RenderBold(text string) string

func RenderCode

func RenderCode(text string) string

func RenderCommand

func RenderCommand(text string) string

func RenderDim

func RenderDim(text string) string

func RenderError

func RenderError(text string) string

func RenderStep

func RenderStep(text string) string

func RenderSuccess

func RenderSuccess(text string) string

func RenderTitle

func RenderTitle(text string) string

func RenderURL

func RenderURL(text string) string

func RenderWarning

func RenderWarning(text string) string

func Select

func Select[T comparable](title string, options []SelectOption[T]) (T, error)

Select displays a selection prompt and returns the chosen value.

func SetVerbose

func SetVerbose(v bool)

SetVerbose enables or disables verbose mode for UI components.

func Step

func Step(text string)

Step prints a step instruction (Light Blue - visible)

func Success

func Success(text string)

Success prints a success message with checkmark (Green)

func Title

func Title(text string)

Title prints a styled title/header (high visibility - Chainlink Blue)

func URL

func URL(text string)

URL prints a styled URL (Chainlink Blue, underlined)

func Warning

func Warning(text string)

Warning prints a warning message to stderr (Yellow)

func WarningWithHelp

func WarningWithHelp(text, suggestion string)

WarningWithHelp prints a warning message with a helpful suggestion to stderr

func WarningWithSuggestions

func WarningWithSuggestions(text string, suggestions []string)

WarningWithSuggestions prints a warning message with multiple suggestions to stderr

func WithSpinner

func WithSpinner(message string, fn func() error) error

WithSpinner executes a function while showing a new spinner. This is a convenience function for single operations.

func WithSpinnerResult

func WithSpinnerResult[T any](message string, fn func() (T, error)) (T, error)

WithSpinnerResult executes a function that returns a value while showing a spinner.

Types

type ConfirmOption

type ConfirmOption func(*confirmConfig)

ConfirmOption configures a Confirm prompt.

func WithDescription

func WithDescription(desc string) ConfirmOption

WithDescription sets the description text for a prompt.

func WithLabels

func WithLabels(affirmative, negative string) ConfirmOption

WithLabels sets custom affirmative/negative button labels for Confirm.

type InputField

type InputField struct {
	Title       string
	Description string
	Placeholder string
	Value       *string
	Validate    func(string) error
	Suggestions []string
}

InputField represents a single field in a multi-field InputForm.

type InputOption

type InputOption func(*inputConfig)

InputOption configures an Input prompt.

func WithInputDescription

func WithInputDescription(desc string) InputOption

WithInputDescription sets the description for an Input prompt.

func WithPlaceholder

func WithPlaceholder(placeholder string) InputOption

WithPlaceholder sets the placeholder text for an Input prompt.

type SelectOption

type SelectOption[T comparable] struct {
	Label string
	Value T
}

SelectOption represents a single option in a Select prompt.

type Spinner

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

Spinner manages a terminal spinner for async operations using Bubble Tea. It uses reference counting to handle multiple concurrent operations - the spinner only stops when ALL operations complete.

func GlobalSpinner

func GlobalSpinner() *Spinner

GlobalSpinner returns the shared spinner instance. This ensures a single spinner is used across PersistentPreRunE and command execution, preventing the spinner from flickering between operations.

func NewSpinner

func NewSpinner() *Spinner

NewSpinner creates a new spinner instance

func (*Spinner) Run

func (s *Spinner) Run(message string, fn func() error) error

Run executes a function while showing the spinner. This handles starting and stopping automatically.

func (*Spinner) Start

func (s *Spinner) Start(message string)

Start begins or continues the spinner with the given message. Each call to Start must be paired with a call to Stop. The spinner will keep running until all Start calls have been matched with Stop calls.

func (*Spinner) Stop

func (s *Spinner) Stop()

Stop decrements the reference count and stops the spinner if count reaches zero

func (*Spinner) StopAll

func (s *Spinner) StopAll()

StopAll forces the spinner to stop regardless of reference count

func (*Spinner) Update

func (s *Spinner) Update(message string)

Update changes the spinner message without affecting the reference count

Jump to

Keyboard shortcuts

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