Documentation
¶
Overview ¶
Package tui provides a comprehensive Terminal User Interface framework for building sophisticated CLI applications with modern UX patterns.
The framework is built on top of Bubble Tea and provides high-level components for common UI patterns including interactive dashboards, file explorers, command palettes, status bars, and modal dialogs.
Key features:
- Interactive dashboards with keyboard navigation and drill-down modals
- StatCards with sparklines, change indicators, and focus states
- Command palettes with fuzzy search
- File explorers with tree navigation
- Status bars with keybinding hints
- Modal dialogs for confirmations and details
- Full keyboard navigation with vim-style bindings
- Responsive layouts that adapt to terminal size
- Theme support via design tokens
Architecture:
All components implement the Component interface, which follows the Bubble Tea pattern with Init/Update/View methods plus Focus/Blur/Focused for focus management.
Components can be composed together to build complex UIs. The Application type provides a container for managing multiple components with automatic focus cycling.
Example usage:
// Create components
dashboard := tui.NewDashboard(
tui.WithDashboardTitle("Metrics"),
tui.WithCards(cpuCard, memCard),
)
dashboard.Focus()
statusBar := tui.NewStatusBar()
statusBar.SetMessage("Ready")
// Run with Bubble Tea
p := tea.NewProgram(model{
dashboard: dashboard,
statusBar: statusBar,
}, tea.WithAltScreen())
p.Run()
For detailed component documentation, see the individual component types.
Index ¶
- Variables
- type ActivityBar
- func (a *ActivityBar) Blur()
- func (a *ActivityBar) Focus()
- func (a *ActivityBar) Focused() bool
- func (a *ActivityBar) Init() tea.Cmd
- func (a *ActivityBar) SetProgress(progress string)
- func (a *ActivityBar) Start(message string) tea.Cmd
- func (a *ActivityBar) Stop()
- func (a *ActivityBar) Update(msg tea.Msg) (Component, tea.Cmd)
- func (a *ActivityBar) View() string
- type ActivityBarOption
- type Application
- type CodeBlock
- func (cb *CodeBlock) Blur()
- func (cb *CodeBlock) Collapse()
- func (cb *CodeBlock) Expand()
- func (cb *CodeBlock) Focus()
- func (cb *CodeBlock) Focused() bool
- func (cb *CodeBlock) Init() tea.Cmd
- func (cb *CodeBlock) IsExpanded() bool
- func (cb *CodeBlock) Toggle()
- func (cb *CodeBlock) Update(msg tea.Msg) (Component, tea.Cmd)
- func (cb *CodeBlock) View() string
- type CodeBlockOption
- func WithCode(code string) CodeBlockOption
- func WithCodeFilename(name string) CodeBlockOption
- func WithCodeLines(lines []string) CodeBlockOption
- func WithCodeMaxLines(max int) CodeBlockOption
- func WithCodeOperation(op string) CodeBlockOption
- func WithCodeSummary(summary string) CodeBlockOption
- func WithExpanded(expanded bool) CodeBlockOption
- func WithLanguage(lang string) CodeBlockOption
- func WithPreviewLines(n int) CodeBlockOption
- func WithStartLine(line int) CodeBlockOption
- type ColumnAlign
- type Command
- type CommandPalette
- func (cp *CommandPalette) Blur()
- func (cp *CommandPalette) Focus()
- func (cp *CommandPalette) Focused() bool
- func (cp *CommandPalette) Hide()
- func (cp *CommandPalette) Init() tea.Cmd
- func (cp *CommandPalette) IsVisible() bool
- func (cp *CommandPalette) Show()
- func (cp *CommandPalette) Update(msg tea.Msg) (Component, tea.Cmd)
- func (cp *CommandPalette) View() string
- type Component
- type ConfirmationBlock
- func (cb *ConfirmationBlock) Blur()
- func (cb *ConfirmationBlock) Focus()
- func (cb *ConfirmationBlock) Focused() bool
- func (cb *ConfirmationBlock) GetSelection() int
- func (cb *ConfirmationBlock) Init() tea.Cmd
- func (cb *ConfirmationBlock) IsConfirmed() bool
- func (cb *ConfirmationBlock) Reset()
- func (cb *ConfirmationBlock) Update(msg tea.Msg) (Component, tea.Cmd)
- func (cb *ConfirmationBlock) View() string
- type ConfirmationBlockOption
- func WithConfirmCode(code string) ConfirmationBlockOption
- func WithConfirmCodeLines(lines []string) ConfirmationBlockOption
- func WithConfirmDescription(desc string) ConfirmationBlockOption
- func WithConfirmFilepath(path string) ConfirmationBlockOption
- func WithConfirmFooterHints(hints []string) ConfirmationBlockOption
- func WithConfirmOperation(op string) ConfirmationBlockOption
- func WithConfirmOptions(options []string) ConfirmationBlockOption
- func WithConfirmPreview(n int) ConfirmationBlockOption
- func WithConfirmStartLine(line int) ConfirmationBlockOption
- type Dashboard
- func (d *Dashboard) AddCard(card *StatCard)
- func (d *Dashboard) Blur()
- func (d *Dashboard) Focus()
- func (d *Dashboard) Focused() bool
- func (d *Dashboard) GetCards() []*StatCard
- func (d *Dashboard) Init() tea.Cmd
- func (d *Dashboard) RemoveCard(index int)
- func (d *Dashboard) SetCards(cards []*StatCard)
- func (d *Dashboard) Update(msg tea.Msg) (Component, tea.Cmd)
- func (d *Dashboard) View() string
- type DashboardOption
- type DataItem
- type DataStatus
- type DetailModal
- func (m *DetailModal) Blur()
- func (m *DetailModal) Focus()
- func (m *DetailModal) Focused() bool
- func (m *DetailModal) Hide()
- func (m *DetailModal) Init() tea.Cmd
- func (m *DetailModal) IsVisible() bool
- func (m *DetailModal) SetContent(card *StatCard)
- func (m *DetailModal) Show()
- func (m *DetailModal) Update(msg tea.Msg) (Component, tea.Cmd)
- func (m *DetailModal) View() string
- type DetailModalOption
- type DiffBlock
- func (db *DiffBlock) Blur()
- func (db *DiffBlock) Collapse()
- func (db *DiffBlock) Expand()
- func (db *DiffBlock) Focus()
- func (db *DiffBlock) Focused() bool
- func (db *DiffBlock) Init() tea.Cmd
- func (db *DiffBlock) IsExpanded() bool
- func (db *DiffBlock) Toggle()
- func (db *DiffBlock) Update(msg tea.Msg) (Component, tea.Cmd)
- func (db *DiffBlock) View() string
- type DiffBlockOption
- func WithDiffContext(n int) DiffBlockOption
- func WithDiffExpanded(expanded bool) DiffBlockOption
- func WithDiffFilename(name string) DiffBlockOption
- func WithDiffLines(lines []DiffLine) DiffBlockOption
- func WithDiffMaxLines(max int) DiffBlockOption
- func WithDiffOperation(op string) DiffBlockOption
- func WithDiffSummary(summary string) DiffBlockOption
- type DiffLine
- type DiffType
- type FileExplorer
- func (fe *FileExplorer) Blur()
- func (fe *FileExplorer) Focus()
- func (fe *FileExplorer) Focused() bool
- func (fe *FileExplorer) GetSelectedNode() *FileNode
- func (fe *FileExplorer) GetSelectedPath() string
- func (fe *FileExplorer) Init() tea.Cmd
- func (fe *FileExplorer) Update(msg tea.Msg) (Component, tea.Cmd)
- func (fe *FileExplorer) View() string
- type FileExplorerOption
- type FileNode
- type Header
- type HeaderColumn
- type HeaderOption
- type HeaderSection
- type IconSet
- type ItemType
- type LayoutHelper
- func (h *LayoutHelper) AbsolutePosition(top, left, width, height float64) *layout.Node
- func (h *LayoutHelper) CardLayout(paddingCh float64) *layout.Node
- func (h *LayoutHelper) CenteredContent() *layout.Node
- func (h *LayoutHelper) CenteredOverlay(width, height float64) *layout.Node
- func (h *LayoutHelper) FixedSizeNode(width, height float64) *layout.Node
- func (h *LayoutHelper) FlexGrowNode(grow float64) *layout.Node
- func (h *LayoutHelper) GridLayout(columns int, gap float64) *layout.Node
- func (h *LayoutHelper) HeaderContentFooterLayout(headerHeight, footerHeight float64) *layout.Node
- func (h *LayoutHelper) HorizontalStackLayout(gap float64) *layout.Node
- func (h *LayoutHelper) ResponsiveGridLayout(minCardWidth, gap float64) *layout.Node
- func (h *LayoutHelper) SidebarLayout(sidebarWidth float64) *layout.Node
- func (h *LayoutHelper) SpaceBetweenRow() *layout.Node
- func (h *LayoutHelper) StackLayout(gap float64) *layout.Node
- func (h *LayoutHelper) ThreeColumnLayout(leftRatio, centerRatio, rightRatio float64) *layout.Node
- func (h *LayoutHelper) TwoColumnLayout(leftRatio, rightRatio float64) *layout.Node
- type Modal
- func (m *Modal) Blur()
- func (m *Modal) Focus()
- func (m *Modal) Focused() bool
- func (m *Modal) Hide()
- func (m *Modal) Init() tea.Cmd
- func (m *Modal) IsVisible() bool
- func (m *Modal) SetMessage(message string)
- func (m *Modal) SetTitle(title string)
- func (m *Modal) Show()
- func (m *Modal) ShowAlert(title, message string, onOK func() tea.Cmd)
- func (m *Modal) ShowConfirm(title, message string, onYes, onNo func() tea.Cmd)
- func (m *Modal) ShowInput(title, message, placeholder string, onOK func(string) tea.Cmd, ...)
- func (m *Modal) Update(msg tea.Msg) (Component, tea.Cmd)
- func (m *Modal) View() string
- type ModalButton
- type ModalOption
- func WithModalButtons(buttons []ModalButton) ModalOption
- func WithModalInput(placeholder string) ModalOption
- func WithModalMessage(message string) ModalOption
- func WithModalOnCancel(fn func() tea.Cmd) ModalOption
- func WithModalOnConfirm(fn func(string) tea.Cmd) ModalOption
- func WithModalTitle(title string) ModalOption
- func WithModalType(t ModalType) ModalOption
- type ModalType
- type Spinner
- type StatCard
- func (s *StatCard) Blur()
- func (s *StatCard) Deselect()
- func (s *StatCard) Focus()
- func (s *StatCard) Focused() bool
- func (s *StatCard) Init() tea.Cmd
- func (s *StatCard) IsSelected() bool
- func (s *StatCard) Select()
- func (s *StatCard) Update(msg tea.Msg) (Component, tea.Cmd)
- func (s *StatCard) View() string
- type StatCardOption
- func WithChange(change int, changePct float64) StatCardOption
- func WithColor(color string) StatCardOption
- func WithSubtitle(subtitle string) StatCardOption
- func WithTitle(title string) StatCardOption
- func WithTrend(trend []float64) StatCardOption
- func WithTrendColor(color string) StatCardOption
- func WithValue(value string) StatCardOption
- type StatusBar
- type StatusBarOption
- type StructuredData
- func (sd *StructuredData) AddColoredRow(key, value, color string) *StructuredData
- func (sd *StructuredData) AddHeader(text string) *StructuredData
- func (sd *StructuredData) AddIndentedRow(key, value string, indent int) *StructuredData
- func (sd *StructuredData) AddIndentedValue(value string, indent int) *StructuredData
- func (sd *StructuredData) AddRow(key, value string) *StructuredData
- func (sd *StructuredData) AddSeparator() *StructuredData
- func (sd *StructuredData) AddValue(value string) *StructuredData
- func (sd *StructuredData) Blur()
- func (sd *StructuredData) Clear() *StructuredData
- func (sd *StructuredData) Focus()
- func (sd *StructuredData) Focused() bool
- func (sd *StructuredData) GetStatus() DataStatus
- func (sd *StructuredData) Init() tea.Cmd
- func (sd *StructuredData) MarkError()
- func (sd *StructuredData) MarkInfo()
- func (sd *StructuredData) MarkSuccess()
- func (sd *StructuredData) MarkWarning()
- func (sd *StructuredData) SetExpanded(expanded bool)
- func (sd *StructuredData) SetItems(items []DataItem) *StructuredData
- func (sd *StructuredData) SetStatus(status DataStatus) tea.Cmd
- func (sd *StructuredData) StartRunning() tea.Cmd
- func (sd *StructuredData) ToggleExpanded()
- func (sd *StructuredData) Update(msg tea.Msg) (Component, tea.Cmd)
- func (sd *StructuredData) View() string
- type StructuredDataOption
- func WithIconSet(iconSet IconSet) StructuredDataOption
- func WithKeyWidth(width int) StructuredDataOption
- func WithRunningColor(color string) StructuredDataOption
- func WithSpinner(spinner Spinner) StructuredDataOption
- func WithStructuredDataDesignTokens(tokens *design.DesignTokens) StructuredDataOption
- func WithStructuredDataIcon(icon string) StructuredDataOption
- func WithStructuredDataMaxLines(n int) StructuredDataOption
- func WithStructuredDataTheme(theme string) StructuredDataOption
- type TextInput
- func (t *TextInput) Blur()
- func (t *TextInput) Focus()
- func (t *TextInput) Focused() bool
- func (t *TextInput) Init() tea.Cmd
- func (t *TextInput) OnSubmit(fn func(string) tea.Cmd)
- func (t *TextInput) Reset()
- func (t *TextInput) SetValue(value string)
- func (t *TextInput) Update(msg tea.Msg) (Component, tea.Cmd)
- func (t *TextInput) Value() string
- func (t *TextInput) View() string
- type ToolBlock
- func (tb *ToolBlock) AppendLine(line string)
- func (tb *ToolBlock) AppendLines(lines []string)
- func (tb *ToolBlock) Blur()
- func (tb *ToolBlock) Focus()
- func (tb *ToolBlock) Focused() bool
- func (tb *ToolBlock) Init() tea.Cmd
- func (tb *ToolBlock) SetExpanded(expanded bool)
- func (tb *ToolBlock) SetStatus(status ToolBlockStatus)
- func (tb *ToolBlock) StartStreaming() tea.Cmd
- func (tb *ToolBlock) StopStreaming()
- func (tb *ToolBlock) StopStreamingWithError()
- func (tb *ToolBlock) ToggleExpanded()
- func (tb *ToolBlock) Update(msg tea.Msg) (Component, tea.Cmd)
- func (tb *ToolBlock) View() string
- type ToolBlockOption
- func WithLineNumbers() ToolBlockOption
- func WithMaxLines(n int) ToolBlockOption
- func WithStatus(status ToolBlockStatus) ToolBlockOption
- func WithStreaming() ToolBlockOption
- func WithToolBlockDesignTokens(tokens *design.DesignTokens) ToolBlockOption
- func WithToolBlockTheme(theme string) ToolBlockOption
- type ToolBlockStatus
Constants ¶
This section is empty.
Variables ¶
var ( // SpinnerDots - Braille dots spinner (smooth) SpinnerDots = Spinner{ Frames: []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"}, } // SpinnerLine - Classic line spinner SpinnerLine = Spinner{ Frames: []string{"─", "\\", "|", "/"}, } // SpinnerCircle - Rotating circle SpinnerCircle = Spinner{ Frames: []string{"◴", "◷", "◶", "◵"}, } // SpinnerThinking - Codex/Claude-style thinking animation (small to large) SpinnerThinking = Spinner{ Frames: []string{".", "+", "*", "÷", "•"}, } // SpinnerCodexThinking - Codex CLI style thinking animation. SpinnerCodexThinking = SpinnerThinking // SpinnerClaudeThinking - Backward-compatible alias for SpinnerThinking. SpinnerClaudeThinking = SpinnerThinking // SpinnerBlink - Simple blink (on/off) SpinnerBlink = Spinner{ Frames: []string{"⏺", " "}, } // SpinnerDotsJumping - Jumping dots SpinnerDotsJumping = Spinner{ Frames: []string{"⢄", "⢂", "⢁", "⡁", "⡈", "⡐", "⡠"}, } // SpinnerArc - Growing arc SpinnerArc = Spinner{ Frames: []string{"◜", "◠", "◝", "◞", "◡", "◟"}, } // SpinnerCircleQuarters - Circle with quarters SpinnerCircleQuarters = Spinner{ Frames: []string{"◐", "◓", "◑", "◒"}, } // SpinnerSquare - Rotating square corners SpinnerSquare = Spinner{ Frames: []string{"◰", "◳", "◲", "◱"}, } // SpinnerArrows - Rotating arrows SpinnerArrows = Spinner{ Frames: []string{"←", "↖", "↑", "↗", "→", "↘", "↓", "↙"}, } // SpinnerBouncingBar - Bouncing bar SpinnerBouncingBar = Spinner{ Frames: []string{"▁", "▂", "▃", "▄", "▅", "▆", "▇", "█", "▇", "▆", "▅", "▄", "▃", "▁"}, } // SpinnerBouncingBall - Bouncing ball SpinnerBouncingBall = Spinner{ Frames: []string{"⠁", "⠂", "⠄", "⡀", "⢀", "⠠", "⠐", "⠈"}, } // SpinnerPulse - Pulsing circle SpinnerPulse = Spinner{ Frames: []string{"○", "◔", "◐", "◕", "●", "◕", "◐", "◔"}, } )
Predefined spinner animations
var ( // IconSetDefault - Default icons IconSetDefault = IconSet{ Running: "⏺", Success: "⏺", Error: "⏺", Warning: "⏺", Info: "⏺", None: "⏺", } // IconSetSymbols - Unicode symbols IconSetSymbols = IconSet{ Running: "⏺", Success: "✓", Error: "✗", Warning: "⚠", Info: "ℹ", None: "⏺", } // IconSetCircles - Circle-based icons IconSetCircles = IconSet{ Running: "○", Success: "●", Error: "◯", Warning: "◐", Info: "○", None: "○", } // IconSetEmoji - Emoji icons IconSetEmoji = IconSet{ Running: "⏺", Success: "✅", Error: "❌", Warning: "⚡", Info: "💡", None: "⏺", } // IconSetMinimal - Minimal ASCII IconSetMinimal = IconSet{ Running: "·", Success: "+", Error: "x", Warning: "!", Info: "i", None: "·", } // IconSetCodex - Codex CLI style IconSetCodex = IconSet{ Running: "⏺", Success: "✓", Error: "✗", Warning: "⚠", Info: "⏺", None: "⏺", } // IconSetClaude - Backward-compatible alias for IconSetCodex. IconSetClaude = IconSet{ Running: IconSetCodex.Running, Success: IconSetCodex.Success, Error: IconSetCodex.Error, Warning: IconSetCodex.Warning, Info: IconSetCodex.Info, None: IconSetCodex.None, } )
Predefined icon sets
var LayoutHelpers = NewLayoutHelper()
Global helper instance for convenience
Functions ¶
This section is empty.
Types ¶
type ActivityBar ¶
type ActivityBar struct {
// contains filtered or unexported fields
}
ActivityBar displays an animated status line with spinner, elapsed time, and progress
func NewActivityBar ¶
func NewActivityBar(opts ...ActivityBarOption) *ActivityBar
NewActivityBar creates a new activity bar
func (*ActivityBar) Blur ¶
func (a *ActivityBar) Blur()
Blur is called when this component loses focus
func (*ActivityBar) Focus ¶
func (a *ActivityBar) Focus()
Focus is called when this component receives focus
func (*ActivityBar) Focused ¶
func (a *ActivityBar) Focused() bool
Focused returns whether this component is currently focused
func (*ActivityBar) SetProgress ¶
func (a *ActivityBar) SetProgress(progress string)
SetProgress updates the progress indicator
func (*ActivityBar) Start ¶
func (a *ActivityBar) Start(message string) tea.Cmd
Start begins the activity animation
type ActivityBarOption ¶ added in v1.1.0
type ActivityBarOption func(*ActivityBar)
ActivityBarOption configures an ActivityBar.
func WithActivityBarDesignTokens ¶ added in v1.1.0
func WithActivityBarDesignTokens(tokens *design.DesignTokens) ActivityBarOption
WithActivityBarDesignTokens applies design-system colors to the activity bar.
func WithActivityBarTheme ¶ added in v1.1.0
func WithActivityBarTheme(theme string) ActivityBarOption
WithActivityBarTheme applies a named design-system theme.
type Application ¶
type Application struct {
// contains filtered or unexported fields
}
Application represents the main TUI application
func NewApplication ¶
func NewApplication() *Application
NewApplication creates a new TUI application
func (*Application) AddComponent ¶
func (a *Application) AddComponent(c Component)
AddComponent adds a component to the application
func (*Application) FocusComponent ¶
func (a *Application) FocusComponent(index int)
FocusComponent focuses a specific component by index, blurring the currently focused one
type CodeBlock ¶
type CodeBlock struct {
// contains filtered or unexported fields
}
CodeBlock displays source code with line numbers, syntax highlighting (future), and collapse/expand
func NewCodeBlock ¶
func NewCodeBlock(opts ...CodeBlockOption) *CodeBlock
NewCodeBlock creates a new code block component
func (*CodeBlock) Focus ¶
func (cb *CodeBlock) Focus()
Focus is called when this component receives focus
func (*CodeBlock) IsExpanded ¶
IsExpanded returns whether the code is currently expanded
type CodeBlockOption ¶
type CodeBlockOption func(*CodeBlock)
CodeBlockOption configures a CodeBlock
func WithCode ¶
func WithCode(code string) CodeBlockOption
WithCode sets the code content from a single string
func WithCodeFilename ¶
func WithCodeFilename(name string) CodeBlockOption
WithCodeFilename sets the filename
func WithCodeLines ¶
func WithCodeLines(lines []string) CodeBlockOption
WithCodeLines sets the code content as lines
func WithCodeMaxLines ¶
func WithCodeMaxLines(max int) CodeBlockOption
WithCodeMaxLines sets maximum lines to show when expanded
func WithCodeOperation ¶
func WithCodeOperation(op string) CodeBlockOption
WithCodeOperation sets the operation type (Write, Read, Edit, etc.)
func WithCodeSummary ¶
func WithCodeSummary(summary string) CodeBlockOption
WithCodeSummary sets the summary text
func WithExpanded ¶
func WithExpanded(expanded bool) CodeBlockOption
WithExpanded sets whether the block starts expanded
func WithLanguage ¶
func WithLanguage(lang string) CodeBlockOption
WithLanguage sets the programming language
func WithPreviewLines ¶
func WithPreviewLines(n int) CodeBlockOption
WithPreviewLines sets number of preview lines when collapsed
func WithStartLine ¶
func WithStartLine(line int) CodeBlockOption
WithStartLine sets the starting line number
type ColumnAlign ¶
type ColumnAlign int
ColumnAlign defines how content is aligned within a column
const ( AlignLeft ColumnAlign = iota AlignCenter AlignRight )
type Command ¶
type Command struct {
Name string // Display name of the command
Description string // Brief description of what the command does
Category string // Category for grouping (e.g., "File", "Edit", "View")
Action func() tea.Cmd // Function to execute when command is selected
Keybinding string // Optional keyboard shortcut (e.g., "Ctrl+S")
}
Command represents an executable command in the command palette with metadata for display and categorization.
type CommandPalette ¶
type CommandPalette struct {
// contains filtered or unexported fields
}
CommandPalette is a fuzzy-searchable command launcher inspired by VS Code's command palette. It provides a popup interface for quickly executing commands via keyboard.
Features:
- Fuzzy search filtering
- Keyboard navigation (↑↓ or j/k)
- Category grouping
- Keybinding hints
- Toggle visibility with Ctrl+K
Example usage:
commands := []tui.Command{
{Name: "Save File", Description: "Save current file", Category: "File", Keybinding: "Ctrl+S"},
{Name: "Open File", Description: "Open a file", Category: "File", Keybinding: "Ctrl+O"},
}
palette := tui.NewCommandPalette(commands)
palette.Show()
func NewCommandPalette ¶
func NewCommandPalette(commands []Command) *CommandPalette
NewCommandPalette creates a new command palette with the given list of commands. The palette is initially hidden and can be shown/hidden with Show() and Hide(), or toggled with Toggle().
The palette displays up to 8 commands at a time and supports fuzzy searching.
func (*CommandPalette) Blur ¶
func (cp *CommandPalette) Blur()
Blur is called when this component loses focus
func (*CommandPalette) Focus ¶
func (cp *CommandPalette) Focus()
Focus is called when this component receives focus
func (*CommandPalette) Focused ¶
func (cp *CommandPalette) Focused() bool
Focused returns whether this component is currently focused
func (*CommandPalette) Init ¶
func (cp *CommandPalette) Init() tea.Cmd
Init initializes the command palette
func (*CommandPalette) IsVisible ¶
func (cp *CommandPalette) IsVisible() bool
IsVisible returns whether the palette is currently visible
func (*CommandPalette) View ¶
func (cp *CommandPalette) View() string
View renders the command palette
type Component ¶
type Component interface {
// Init initializes the component
Init() tea.Cmd
// Update handles messages and updates component state
Update(msg tea.Msg) (Component, tea.Cmd)
// View renders the component
View() string
// Focus is called when this component receives focus
Focus()
// Blur is called when this component loses focus
Blur()
// Focused returns whether this component is currently focused
Focused() bool
}
Component is the interface all TUI components must implement
type ConfirmationBlock ¶
type ConfirmationBlock struct {
// contains filtered or unexported fields
}
ConfirmationBlock displays file operations with code preview and multiple choice confirmation
func NewConfirmationBlock ¶
func NewConfirmationBlock(opts ...ConfirmationBlockOption) *ConfirmationBlock
NewConfirmationBlock creates a new confirmation block
func (*ConfirmationBlock) Blur ¶
func (cb *ConfirmationBlock) Blur()
Blur is called when this component loses focus
func (*ConfirmationBlock) Focus ¶
func (cb *ConfirmationBlock) Focus()
Focus is called when this component receives focus
func (*ConfirmationBlock) Focused ¶
func (cb *ConfirmationBlock) Focused() bool
Focused returns whether this component is currently focused
func (*ConfirmationBlock) GetSelection ¶
func (cb *ConfirmationBlock) GetSelection() int
GetSelection returns the selected option index (-1 if cancelled)
func (*ConfirmationBlock) Init ¶
func (cb *ConfirmationBlock) Init() tea.Cmd
Init initializes the confirmation block
func (*ConfirmationBlock) IsConfirmed ¶
func (cb *ConfirmationBlock) IsConfirmed() bool
IsConfirmed returns whether the user has made a choice
func (*ConfirmationBlock) Reset ¶
func (cb *ConfirmationBlock) Reset()
Reset resets the confirmation state
func (*ConfirmationBlock) View ¶
func (cb *ConfirmationBlock) View() string
View renders the confirmation block
type ConfirmationBlockOption ¶
type ConfirmationBlockOption func(*ConfirmationBlock)
ConfirmationBlockOption configures a ConfirmationBlock
func WithConfirmCode ¶
func WithConfirmCode(code string) ConfirmationBlockOption
WithConfirmCode sets the code content
func WithConfirmCodeLines ¶
func WithConfirmCodeLines(lines []string) ConfirmationBlockOption
WithConfirmCodeLines sets the code content as lines
func WithConfirmDescription ¶
func WithConfirmDescription(desc string) ConfirmationBlockOption
WithConfirmDescription sets the description text
func WithConfirmFilepath ¶
func WithConfirmFilepath(path string) ConfirmationBlockOption
WithConfirmFilepath sets the file path
func WithConfirmFooterHints ¶
func WithConfirmFooterHints(hints []string) ConfirmationBlockOption
WithConfirmFooterHints sets footer hint text
func WithConfirmOperation ¶
func WithConfirmOperation(op string) ConfirmationBlockOption
WithConfirmOperation sets the operation type
func WithConfirmOptions ¶
func WithConfirmOptions(options []string) ConfirmationBlockOption
WithConfirmOptions sets the confirmation options
func WithConfirmPreview ¶
func WithConfirmPreview(n int) ConfirmationBlockOption
WithConfirmPreview sets number of preview lines (0 = show all)
func WithConfirmStartLine ¶
func WithConfirmStartLine(line int) ConfirmationBlockOption
WithConfirmStartLine sets the starting line number
type Dashboard ¶
type Dashboard struct {
// contains filtered or unexported fields
}
Dashboard displays multiple stat cards in a responsive grid layout with interactive keyboard navigation. It supports arrow keys (←→↑↓) and vim-style (hjkl) navigation, visual focus states, and drill-down modals for detailed metric views.
The dashboard automatically calculates card dimensions based on the terminal size and configured layout (fixed columns or responsive grid). Cards can be navigated using keyboard controls, and pressing Enter on a focused card opens a DetailModal with expanded metrics and trend graphs.
Example usage:
dashboard := tui.NewDashboard(
tui.WithDashboardTitle("System Metrics"),
tui.WithResponsiveLayout(30),
tui.WithCards(cpuCard, memoryCard, diskCard),
)
dashboard.Focus()
func NewDashboard ¶
func NewDashboard(opts ...DashboardOption) *Dashboard
NewDashboard creates a new dashboard with the given configuration options.
Defaults:
- columns: 3
- gap: 2 characters
- minCardWidth: 30 characters
- responsive: true
- theme: DefaultTheme()
The dashboard automatically focuses the first card if cards are provided. Use WithCards, WithGridColumns, WithResponsiveLayout, and other options to customize.
func (*Dashboard) AddCard ¶
AddCard adds a stat card to the dashboard and updates card dimensions to fit the current layout. Cards are appended to the end of the grid.
func (*Dashboard) Focus ¶
func (d *Dashboard) Focus()
Focus is called when this component receives focus
func (*Dashboard) GetCards ¶
GetCards returns a slice of all stat cards currently in the dashboard. The returned slice is the internal slice, not a copy.
func (*Dashboard) RemoveCard ¶
RemoveCard removes a stat card from the dashboard by index and updates card dimensions to fit the new layout. Silently ignores invalid indices.
func (*Dashboard) SetCards ¶
SetCards replaces all stat cards in the dashboard and updates card dimensions to fit the new layout.
func (*Dashboard) Update ¶
Update handles Bubble Tea messages including window resize and keyboard navigation.
Window resize messages (tea.WindowSizeMsg) trigger recalculation of card dimensions.
Keyboard controls (when focused):
- ←, h: Move focus left
- →, l: Move focus right
- ↑, k: Move focus up (grid-aware)
- ↓, j: Move focus down (grid-aware)
- Enter: Open DetailModal for focused card
- ESC: Clear selection
When the DetailModal is visible, all keyboard input is forwarded to it. When the modal closes, focus returns to the dashboard.
func (*Dashboard) View ¶
View renders the dashboard as a string, displaying all cards in a grid layout.
If a DetailModal is visible, it is overlayed on top of the dashboard view. The rendering uses line-by-line compositing to merge the modal and dashboard views.
Returns an empty string if the dashboard width is zero or there are no cards.
type DashboardOption ¶
type DashboardOption func(*Dashboard)
DashboardOption configures a Dashboard
func WithCards ¶
func WithCards(cards ...*StatCard) DashboardOption
WithCards sets the stat cards to display
func WithDashboardTitle ¶
func WithDashboardTitle(title string) DashboardOption
WithDashboardTitle sets the dashboard title
func WithGridColumns ¶
func WithGridColumns(columns int) DashboardOption
WithGridColumns sets the number of columns in the grid
func WithResponsiveLayout ¶
func WithResponsiveLayout(minCardWidth float64) DashboardOption
WithResponsiveLayout enables responsive grid layout
type DataItem ¶
type DataItem struct {
Type ItemType
Key string
Value string
Indent int // Indentation level (0 = no indent, 1 = one level, etc.)
Color string // Optional ANSI color code (e.g., "\033[32m" for green)
}
DataItem represents a single item in structured data
type DataStatus ¶
type DataStatus int
DataStatus represents the status of the data display
const ( DataStatusNone DataStatus = iota DataStatusRunning DataStatusSuccess DataStatusError DataStatusWarning DataStatusInfo )
type DetailModal ¶
type DetailModal struct {
// contains filtered or unexported fields
}
DetailModal displays detailed information about a StatCard in a centered overlay modal. It shows expanded metrics including an 8-line trend graph, statistics (min, max, avg), change indicators, and optional historical data.
The modal is typically opened by pressing Enter on a focused card in a Dashboard. It can be closed by pressing ESC or 'q'.
Visual layout:
- Centered at 70% width and 80% height of the viewport
- Double-line borders with title
- Large 8-line trend graph using Unicode blocks (▀▄█)
- Statistics section (min, max, average)
- Optional historical data section
Example usage:
modal := tui.NewDetailModal() modal.SetContent(statCard) modal.Show() // Opens the modal // ... user closes with ESC modal.IsVisible() // Returns false after close
func NewDetailModal ¶
func NewDetailModal(opts ...DetailModalOption) *DetailModal
NewDetailModal creates a new detail modal with the given configuration options.
The modal is initially hidden and must be shown with Show(). Use SetContent to populate the modal with data from a StatCard, then Show() to display it.
Defaults:
- visible: false
- theme: DefaultTheme()
- history: empty slice
func (*DetailModal) Blur ¶
func (m *DetailModal) Blur()
Blur is called when this component loses focus
func (*DetailModal) Focus ¶
func (m *DetailModal) Focus()
Focus is called when this component receives focus
func (*DetailModal) Focused ¶
func (m *DetailModal) Focused() bool
Focused returns whether this component is currently focused
func (*DetailModal) Hide ¶
func (m *DetailModal) Hide()
Hide hides the modal and removes focus. This is typically called when the user presses ESC or 'q' to close the modal.
func (*DetailModal) IsVisible ¶
func (m *DetailModal) IsVisible() bool
IsVisible returns whether the modal is visible
func (*DetailModal) SetContent ¶
func (m *DetailModal) SetContent(card *StatCard)
SetContent updates the modal content from a StatCard, copying all relevant fields including title, value, subtitle, change data, trend data, and colors. This should be called before Show() to populate the modal with the card's data.
func (*DetailModal) Show ¶
func (m *DetailModal) Show()
Show displays the modal and sets it as focused. Call this after populating the modal with SetContent to display it to the user.
func (*DetailModal) Update ¶
Update handles Bubble Tea messages including window resize and keyboard input.
Window resize messages (tea.WindowSizeMsg) update the modal's dimensions for centering.
Keyboard controls (when visible and focused):
- ESC, q: Close the modal
Messages are only processed when the modal is both visible and focused.
func (*DetailModal) View ¶
func (m *DetailModal) View() string
View renders the modal as a centered overlay. Returns an empty string if the modal is not visible or width is zero.
The modal is sized at 70% of viewport width (minimum 60 chars) and 80% of viewport height (minimum 20 lines), and centered both horizontally and vertically.
type DetailModalOption ¶
type DetailModalOption func(*DetailModal)
DetailModalOption configures a DetailModal
func WithHistory ¶
func WithHistory(history []string) DetailModalOption
WithHistory sets historical data points
func WithModalContent ¶
func WithModalContent(card *StatCard) DetailModalOption
WithModalContent sets the content from a StatCard
type DiffBlock ¶
type DiffBlock struct {
// contains filtered or unexported fields
}
DiffBlock displays code changes with +/- indicators
func NewDiffBlock ¶
func NewDiffBlock(opts ...DiffBlockOption) *DiffBlock
NewDiffBlock creates a new diff block component
func NewDiffBlockFromStrings ¶
func NewDiffBlockFromStrings(old, new string, opts ...DiffBlockOption) *DiffBlock
NewDiffBlockFromStrings creates a diff block from old and new content strings
func (*DiffBlock) Focus ¶
func (db *DiffBlock) Focus()
Focus is called when this component receives focus
func (*DiffBlock) IsExpanded ¶
IsExpanded returns whether the diff is currently expanded
type DiffBlockOption ¶
type DiffBlockOption func(*DiffBlock)
DiffBlockOption configures a DiffBlock
func WithDiffContext ¶
func WithDiffContext(n int) DiffBlockOption
WithDiffContext sets number of context lines
func WithDiffExpanded ¶
func WithDiffExpanded(expanded bool) DiffBlockOption
WithDiffExpanded sets whether the block starts expanded
func WithDiffFilename ¶
func WithDiffFilename(name string) DiffBlockOption
WithDiffFilename sets the filename
func WithDiffLines ¶
func WithDiffLines(lines []DiffLine) DiffBlockOption
WithDiffLines sets the diff content
func WithDiffMaxLines ¶
func WithDiffMaxLines(max int) DiffBlockOption
WithDiffMaxLines sets maximum lines to show
func WithDiffOperation ¶
func WithDiffOperation(op string) DiffBlockOption
WithDiffOperation sets the operation type
func WithDiffSummary ¶
func WithDiffSummary(summary string) DiffBlockOption
WithDiffSummary sets the summary text
type DiffLine ¶
type DiffLine struct {
Type DiffType // Added, Removed, or Unchanged
Content string // Line content
LineNum int // Line number (for context)
}
DiffLine represents a single line in a diff
type FileExplorer ¶
type FileExplorer struct {
// contains filtered or unexported fields
}
FileExplorer displays a navigable file tree
func NewFileExplorer ¶
func NewFileExplorer(path string, opts ...FileExplorerOption) *FileExplorer
NewFileExplorer creates a new file explorer starting at the given path
func (*FileExplorer) Blur ¶
func (fe *FileExplorer) Blur()
Blur is called when this component loses focus
func (*FileExplorer) Focus ¶
func (fe *FileExplorer) Focus()
Focus is called when this component receives focus
func (*FileExplorer) Focused ¶
func (fe *FileExplorer) Focused() bool
Focused returns whether this component is currently focused
func (*FileExplorer) GetSelectedNode ¶
func (fe *FileExplorer) GetSelectedNode() *FileNode
GetSelectedNode returns the currently selected node
func (*FileExplorer) GetSelectedPath ¶
func (fe *FileExplorer) GetSelectedPath() string
GetSelectedPath returns the path of the currently selected node
func (*FileExplorer) Init ¶
func (fe *FileExplorer) Init() tea.Cmd
Init initializes the file explorer
type FileExplorerOption ¶
type FileExplorerOption func(*FileExplorer)
FileExplorerOption configures a FileExplorer
func WithShowHidden ¶
func WithShowHidden(show bool) FileExplorerOption
WithShowHidden shows hidden files (starting with .)
type FileNode ¶
type FileNode struct {
Name string
Path string
IsDir bool
Children []*FileNode
Expanded bool
Parent *FileNode
}
FileNode represents a file or directory in the tree
type Header ¶
type Header struct {
// contains filtered or unexported fields
}
Header displays a multi-column header using the layout system
func NewHeader ¶
func NewHeader(opts ...HeaderOption) *Header
NewHeader creates a new header component
type HeaderColumn ¶
type HeaderColumn struct {
Width int // Flex-grow value (0 = equal distribution with others)
Align ColumnAlign // Content alignment
Content []string // Lines of content
}
HeaderColumn represents a column in the header
type HeaderOption ¶
type HeaderOption func(*Header)
HeaderOption configures a Header
func WithColumnSections ¶
func WithColumnSections(columnIndex int, sections ...HeaderSection) HeaderOption
WithColumnSections sets sections for a specific column
func WithColumns ¶
func WithColumns(columns ...HeaderColumn) HeaderOption
WithColumns sets the columns for the header
func WithVerticalDivider ¶
func WithVerticalDivider(show bool) HeaderOption
WithVerticalDivider enables/disables the vertical divider between columns
type HeaderSection ¶
type HeaderSection struct {
Title string // Section title (optional)
Content []string // Section content lines
Divider bool // Show horizontal divider before section
}
HeaderSection represents a section within a column with optional divider
type IconSet ¶
type IconSet struct {
Running string
Success string
Error string
Warning string
Info string
None string
}
IconSet defines icons for different statuses
type LayoutHelper ¶
type LayoutHelper struct{}
LayoutHelper provides common layout patterns and utilities
func NewLayoutHelper ¶
func NewLayoutHelper() *LayoutHelper
NewLayoutHelper creates a new layout helper
func (*LayoutHelper) AbsolutePosition ¶
func (h *LayoutHelper) AbsolutePosition(top, left, width, height float64) *layout.Node
AbsolutePosition creates a node with absolute positioning Useful for overlays, tooltips, floating elements
func (*LayoutHelper) CardLayout ¶
func (h *LayoutHelper) CardLayout(paddingCh float64) *layout.Node
CardLayout creates a card-style container with padding and borders paddingCh is padding in characters
func (*LayoutHelper) CenteredContent ¶
func (h *LayoutHelper) CenteredContent() *layout.Node
CenteredContent creates a container with centered content
func (*LayoutHelper) CenteredOverlay ¶
func (h *LayoutHelper) CenteredOverlay(width, height float64) *layout.Node
CenteredOverlay creates a centered overlay node (perfect for modals, dialogs) width and height are in viewport units (e.g., 60, 20 for 60ch x 20ch)
func (*LayoutHelper) FixedSizeNode ¶
func (h *LayoutHelper) FixedSizeNode(width, height float64) *layout.Node
FixedSizeNode creates a node with fixed width and height
func (*LayoutHelper) FlexGrowNode ¶
func (h *LayoutHelper) FlexGrowNode(grow float64) *layout.Node
FlexGrowNode creates a simple node that grows to fill available space
func (*LayoutHelper) GridLayout ¶
func (h *LayoutHelper) GridLayout(columns int, gap float64) *layout.Node
GridLayout creates a CSS Grid layout with specified columns and rows columns is the number of columns, gap is the spacing between cells
func (*LayoutHelper) HeaderContentFooterLayout ¶
func (h *LayoutHelper) HeaderContentFooterLayout(headerHeight, footerHeight float64) *layout.Node
HeaderContentFooterLayout creates a classic header/content/footer layout headerHeight and footerHeight are in characters
func (*LayoutHelper) HorizontalStackLayout ¶
func (h *LayoutHelper) HorizontalStackLayout(gap float64) *layout.Node
HorizontalStackLayout creates a horizontal stack with gap between items
func (*LayoutHelper) ResponsiveGridLayout ¶
func (h *LayoutHelper) ResponsiveGridLayout(minCardWidth, gap float64) *layout.Node
ResponsiveGridLayout creates a grid that adapts to viewport width minCardWidth is the minimum width for each card in characters gap is the spacing between cards
func (*LayoutHelper) SidebarLayout ¶
func (h *LayoutHelper) SidebarLayout(sidebarWidth float64) *layout.Node
SidebarLayout creates a sidebar + main content layout sidebarWidth is in characters (e.g., 20 for 20ch)
func (*LayoutHelper) SpaceBetweenRow ¶
func (h *LayoutHelper) SpaceBetweenRow() *layout.Node
SpaceBetweenRow creates a row with space-between justification Perfect for toolbars, headers with left/right content
func (*LayoutHelper) StackLayout ¶
func (h *LayoutHelper) StackLayout(gap float64) *layout.Node
StackLayout creates a vertical stack with gap between items
func (*LayoutHelper) ThreeColumnLayout ¶
func (h *LayoutHelper) ThreeColumnLayout(leftRatio, centerRatio, rightRatio float64) *layout.Node
ThreeColumnLayout creates a three-column layout with adjustable ratios
func (*LayoutHelper) TwoColumnLayout ¶
func (h *LayoutHelper) TwoColumnLayout(leftRatio, rightRatio float64) *layout.Node
TwoColumnLayout creates a two-column layout with adjustable ratio leftRatio:rightRatio determines the flex-grow distribution (e.g., 1:2)
type Modal ¶
type Modal struct {
// contains filtered or unexported fields
}
Modal displays overlay dialogs for user interaction
func (*Modal) SetMessage ¶
SetMessage updates the modal message
func (*Modal) ShowConfirm ¶
ShowConfirm displays a confirmation modal
func (*Modal) ShowInput ¶
func (m *Modal) ShowInput(title, message, placeholder string, onOK func(string) tea.Cmd, onCancel func() tea.Cmd)
ShowInput displays an input modal
type ModalButton ¶
type ModalButton struct {
Label string
Action func(string) tea.Cmd // Input value passed for ModalInput, empty string otherwise
}
ModalButton represents a button in the modal
type ModalOption ¶
type ModalOption func(*Modal)
ModalOption configures a Modal
func WithModalButtons ¶
func WithModalButtons(buttons []ModalButton) ModalOption
WithModalButtons sets custom buttons
func WithModalInput ¶
func WithModalInput(placeholder string) ModalOption
WithModalInput enables text input (for ModalInput type)
func WithModalMessage ¶
func WithModalMessage(message string) ModalOption
WithModalMessage sets the modal message
func WithModalOnCancel ¶
func WithModalOnCancel(fn func() tea.Cmd) ModalOption
WithModalOnCancel sets the cancel callback
func WithModalOnConfirm ¶
func WithModalOnConfirm(fn func(string) tea.Cmd) ModalOption
WithModalOnConfirm sets the confirm callback
func WithModalTitle ¶
func WithModalTitle(title string) ModalOption
WithModalTitle sets the modal title
type Spinner ¶
type Spinner struct {
Frames []string
}
Spinner defines an animation sequence
func (Spinner) FrameCount ¶
FrameCount returns the number of frames in the spinner
type StatCard ¶
type StatCard struct {
// contains filtered or unexported fields
}
StatCard displays a single metric with title, value, change indicator, and optional sparkline trend visualization. Cards support three visual states:
- Normal: Thin single-line borders (┌─┐)
- Focused: Double-line cyan borders (╔═╗)
- Selected: Thick yellow borders (┏━┓)
StatCards are typically used within a Dashboard for displaying multiple metrics in a grid layout. They render change indicators with directional arrows (↑↓→) and optional Unicode sparklines using block characters (▁▂▃▄▅▆▇█).
Example usage:
card := tui.NewStatCard(
tui.WithTitle("CPU Usage"),
tui.WithValue("42%"),
tui.WithChange(5, 13.5),
tui.WithTrend([]float64{35, 38, 40, 42, 45}),
)
func NewStatCard ¶
func NewStatCard(opts ...StatCardOption) *StatCard
NewStatCard creates a new stat card with the given configuration options.
Defaults:
- width: 30 characters
- height: 8 lines
- color: #2196F3 (blue)
- trendColor: #4CAF50 (green)
- theme: DefaultTheme()
Use WithTitle, WithValue, WithChange, WithTrend, and other options to customize the card's content and appearance.
func (*StatCard) Focus ¶
func (s *StatCard) Focus()
Focus is called when this component receives focus
func (*StatCard) IsSelected ¶
IsSelected returns whether this card is selected
func (*StatCard) Select ¶
func (s *StatCard) Select()
Select marks the card as selected (for drill-down)
type StatCardOption ¶
type StatCardOption func(*StatCard)
StatCardOption configures a StatCard
func WithChange ¶
func WithChange(change int, changePct float64) StatCardOption
WithChange sets the change value and percentage
func WithSubtitle ¶
func WithSubtitle(subtitle string) StatCardOption
WithSubtitle sets the subtitle/description
func WithTrend ¶
func WithTrend(trend []float64) StatCardOption
WithTrend sets the sparkline trend data
func WithTrendColor ¶
func WithTrendColor(color string) StatCardOption
WithTrendColor sets the trend line color
func WithValue ¶
func WithValue(value string) StatCardOption
WithValue sets the main value to display
type StatusBar ¶
type StatusBar struct {
// contains filtered or unexported fields
}
StatusBar displays status information and keybindings at the bottom of the screen. It shows a status message on the left and keybinding hints on the right, with automatic truncation when the terminal is narrow.
Visual styling changes based on focus state:
- Focused: Inverted colors (black on white)
- Unfocused: Dimmed text
Example usage:
statusBar := tui.NewStatusBar()
statusBar.SetMessage("Processing...")
// Later: statusBar.SetMessage("Complete!")
func NewStatusBar ¶
func NewStatusBar(opts ...StatusBarOption) *StatusBar
NewStatusBar creates a new status bar with the default message "Ready".
func (*StatusBar) Focus ¶
func (s *StatusBar) Focus()
Focus is called when this component receives focus
func (*StatusBar) SetMessage ¶
SetMessage updates the status message displayed on the left side of the status bar. The message will be automatically truncated with "..." if the terminal is too narrow to display both the message and keybinding hints.
type StatusBarOption ¶ added in v1.1.0
type StatusBarOption func(*StatusBar)
StatusBarOption configures a StatusBar.
func WithStatusBarDesignTokens ¶ added in v1.1.0
func WithStatusBarDesignTokens(tokens *design.DesignTokens) StatusBarOption
WithStatusBarDesignTokens applies design-system colors to the status bar.
func WithStatusBarTheme ¶ added in v1.1.0
func WithStatusBarTheme(theme string) StatusBarOption
WithStatusBarTheme applies a named design-system theme.
type StructuredData ¶
type StructuredData struct {
// contains filtered or unexported fields
}
StructuredData displays formatted key-value data with tree connectors
func FromKeyValuePairs ¶
func FromKeyValuePairs(title string, pairs ...string) *StructuredData
FromKeyValuePairs creates structured data from alternating key-value strings
func FromMap ¶
func FromMap(title string, data map[string]string) *StructuredData
FromMap creates structured data from a map
func NewStructuredData ¶
func NewStructuredData(title string, opts ...StructuredDataOption) *StructuredData
NewStructuredData creates a new structured data component
func (*StructuredData) AddColoredRow ¶
func (sd *StructuredData) AddColoredRow(key, value, color string) *StructuredData
AddColoredRow adds a key-value row with custom color
func (*StructuredData) AddHeader ¶
func (sd *StructuredData) AddHeader(text string) *StructuredData
AddHeader adds a section header
func (*StructuredData) AddIndentedRow ¶
func (sd *StructuredData) AddIndentedRow(key, value string, indent int) *StructuredData
AddIndentedRow adds an indented key-value row
func (*StructuredData) AddIndentedValue ¶
func (sd *StructuredData) AddIndentedValue(value string, indent int) *StructuredData
AddIndentedValue adds an indented value-only line
func (*StructuredData) AddRow ¶
func (sd *StructuredData) AddRow(key, value string) *StructuredData
AddRow adds a key-value row
func (*StructuredData) AddSeparator ¶
func (sd *StructuredData) AddSeparator() *StructuredData
AddSeparator adds a blank line
func (*StructuredData) AddValue ¶
func (sd *StructuredData) AddValue(value string) *StructuredData
AddValue adds a value-only line (no key)
func (*StructuredData) Blur ¶
func (sd *StructuredData) Blur()
Blur is called when this component loses focus
func (*StructuredData) Clear ¶
func (sd *StructuredData) Clear() *StructuredData
Clear removes all items
func (*StructuredData) Focus ¶
func (sd *StructuredData) Focus()
Focus is called when this component receives focus
func (*StructuredData) Focused ¶
func (sd *StructuredData) Focused() bool
Focused returns whether this component is currently focused
func (*StructuredData) GetStatus ¶
func (sd *StructuredData) GetStatus() DataStatus
GetStatus returns the current status
func (*StructuredData) Init ¶
func (sd *StructuredData) Init() tea.Cmd
Init initializes the structured data component
func (*StructuredData) MarkError ¶
func (sd *StructuredData) MarkError()
MarkError sets status to error (red icon, no animation)
func (*StructuredData) MarkInfo ¶
func (sd *StructuredData) MarkInfo()
MarkInfo sets status to info (white icon, no animation)
func (*StructuredData) MarkSuccess ¶
func (sd *StructuredData) MarkSuccess()
MarkSuccess sets status to success (green icon, no animation)
func (*StructuredData) MarkWarning ¶
func (sd *StructuredData) MarkWarning()
MarkWarning sets status to warning (yellow icon, no animation)
func (*StructuredData) SetExpanded ¶
func (sd *StructuredData) SetExpanded(expanded bool)
SetExpanded sets the expanded state
func (*StructuredData) SetItems ¶
func (sd *StructuredData) SetItems(items []DataItem) *StructuredData
SetItems replaces all items (for batch operations)
func (*StructuredData) SetStatus ¶
func (sd *StructuredData) SetStatus(status DataStatus) tea.Cmd
SetStatus sets the status and starts/stops animation
func (*StructuredData) StartRunning ¶
func (sd *StructuredData) StartRunning() tea.Cmd
StartRunning sets status to running and begins animation
func (*StructuredData) ToggleExpanded ¶
func (sd *StructuredData) ToggleExpanded()
ToggleExpanded toggles the expanded state
func (*StructuredData) View ¶
func (sd *StructuredData) View() string
View renders the structured data
type StructuredDataOption ¶
type StructuredDataOption func(*StructuredData)
StructuredDataOption configures a StructuredData
func WithIconSet ¶
func WithIconSet(iconSet IconSet) StructuredDataOption
WithIconSet sets the icon set for status indicators
func WithKeyWidth ¶
func WithKeyWidth(width int) StructuredDataOption
WithKeyWidth sets a fixed width for the key column
func WithRunningColor ¶
func WithRunningColor(color string) StructuredDataOption
WithRunningColor sets the color for the running status animation
func WithSpinner ¶
func WithSpinner(spinner Spinner) StructuredDataOption
WithSpinner sets the spinner animation
func WithStructuredDataDesignTokens ¶ added in v1.1.0
func WithStructuredDataDesignTokens(tokens *design.DesignTokens) StructuredDataOption
WithStructuredDataDesignTokens applies design-system colors to status rendering.
func WithStructuredDataIcon ¶
func WithStructuredDataIcon(icon string) StructuredDataOption
WithIcon sets a custom icon
func WithStructuredDataMaxLines ¶
func WithStructuredDataMaxLines(n int) StructuredDataOption
WithMaxLines sets the maximum lines to show when collapsed
func WithStructuredDataTheme ¶ added in v1.1.0
func WithStructuredDataTheme(theme string) StructuredDataOption
WithStructuredDataTheme applies a named design-system theme. Supported names: default, midnight, nord, paper, wrapped.
type TextInput ¶
type TextInput struct {
// contains filtered or unexported fields
}
TextInput is a multi-line text input component for user messages
func (*TextInput) Focus ¶
func (t *TextInput) Focus()
Focus is called when this component receives focus
type ToolBlock ¶
type ToolBlock struct {
// contains filtered or unexported fields
}
ToolBlock represents a collapsible block showing tool execution results
func NewToolBlock ¶
func NewToolBlock(toolName, command string, output []string, opts ...ToolBlockOption) *ToolBlock
NewToolBlock creates a new tool block
func (*ToolBlock) AppendLine ¶
AppendLine adds a single line to the output (for streaming)
func (*ToolBlock) AppendLines ¶
AppendLines adds multiple lines to the output (for streaming)
func (*ToolBlock) Focus ¶
func (tb *ToolBlock) Focus()
Focus is called when this component receives focus
func (*ToolBlock) SetExpanded ¶
SetExpanded sets the expanded state
func (*ToolBlock) SetStatus ¶
func (tb *ToolBlock) SetStatus(status ToolBlockStatus)
SetStatus updates the status and stops streaming if completed
func (*ToolBlock) StartStreaming ¶
StartStreaming begins streaming mode with running status
func (*ToolBlock) StopStreaming ¶
func (tb *ToolBlock) StopStreaming()
StopStreaming stops streaming and sets status to complete
func (*ToolBlock) StopStreamingWithError ¶
func (tb *ToolBlock) StopStreamingWithError()
StopStreamingWithError stops streaming and sets status to error
func (*ToolBlock) ToggleExpanded ¶
func (tb *ToolBlock) ToggleExpanded()
ToggleExpanded toggles the expanded state
type ToolBlockOption ¶
type ToolBlockOption func(*ToolBlock)
ToolBlockOption configures a ToolBlock
func WithMaxLines ¶
func WithMaxLines(n int) ToolBlockOption
WithMaxLines sets the maximum lines to show when collapsed
func WithStatus ¶
func WithStatus(status ToolBlockStatus) ToolBlockOption
WithStatus sets the initial status
func WithStreaming ¶
func WithStreaming() ToolBlockOption
WithStreaming enables streaming mode for real-time output
func WithToolBlockDesignTokens ¶ added in v1.1.0
func WithToolBlockDesignTokens(tokens *design.DesignTokens) ToolBlockOption
WithToolBlockDesignTokens applies design-system colors to status rendering.
func WithToolBlockTheme ¶ added in v1.1.0
func WithToolBlockTheme(theme string) ToolBlockOption
WithToolBlockTheme applies a named design-system theme.
type ToolBlockStatus ¶
type ToolBlockStatus int
ToolBlockStatus represents the execution state
const ( StatusRunning ToolBlockStatus = iota StatusComplete StatusError StatusWarning )
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
basic
command
|
|
|
claude_code_demo
command
|
|
|
code_demo
command
|
|
|
codex_code_demo
command
|
|
|
confirmation_demo
command
|
|
|
diff_example
command
|
|
|
fileexplorer_demo
command
|
|
|
header_demo
command
|
|
|
header_demo_preview
command
|
|
|
input_demo
command
|
|
|
kitchen_sink
command
|
|
|
kitchen_sink_inline
command
|
|
|
layout_demo
command
|
|
|
modal_demo
command
|
|
|
spinner_showcase
command
|
|
|
streaming_demo
command
|
|
|
structureddata_animation_demo
command
|
|
|
structureddata_demo
command
|
|
|
thinking_spinner_demo
command
|
|
|
Package table provides static table rendering for CLI output.
|
Package table provides static table rendering for CLI output. |
|
example
command
|