Skip to content

ui

import "go-cli-template/internal/ui"

Index

func ApplyFrameListSize

func ApplyFrameListSize(model *list.Model, width, height int, opts FrameSizeOptions)

ApplyFrameListSize clamps a list to fit a framed container.

func ApplyListFilterStyles

func ApplyListFilterStyles(model *list.Model, theme Theme)

ApplyListFilterStyles sets shared filter styles for lists.

func ApplyListStyles

func ApplyListStyles(model *list.Model, theme Theme)

ApplyListStyles sets shared list styles.

func ClipboardConfirm

func ClipboardConfirm(theme Theme) string

ClipboardConfirm renders the standard clipboard confirmation message.

func ConfigureTextarea

func ConfigureTextarea(input *textarea.Model, theme Theme, altEnterSubmit bool) (key.Binding, key.Binding)

ConfigureTextarea applies shared styles and keybindings for multi-line input.

func ExitMessage

func ExitMessage(theme Theme, message string, mutedText bool) string

ExitMessage renders a standard framed exit message.

func FrameStyle

func FrameStyle(theme Theme) lipgloss.Style

FrameStyle defines a shared container style for bordered views.

func ListFullHelpSections

func ListFullHelpSections(model list.Model, opts ListHelpOptions) [][]key.Binding

func ListHelpView

func ListHelpView(model list.Model, short []key.Binding, full [][]key.Binding) string

func NewListDelegate

func NewListDelegate(theme Theme, opts ListDelegateOptions) list.ItemDelegate

NewListDelegate provides shared list focus styles.

func NewListModel

func NewListModel(items []list.Item, delegate list.ItemDelegate, width, height int, theme Theme) list.Model

NewListModel creates a list with shared styles applied.

func PromptConfirmation

func PromptConfirmation(title, prompt string, theme Theme) (bool, error)

PromptConfirmation runs a confirmation dialog and returns the user’s choice

func TextareaKeyBindings

func TextareaKeyBindings(altEnterSubmit bool) (key.Binding, key.Binding)

TextareaKeyBindings returns submit and newline bindings based on config.

func TextareaSubmitHelp

func TextareaSubmitHelp(submitKey key.Binding, action string) string

TextareaSubmitHelp formats the key help for a multi-line submit action.

type Breakpoint

Breakpoint defines responsive size categories.

type Breakpoint int

const (
// BreakpointXS represents extra small screens (< 40 columns).
BreakpointXS Breakpoint = iota
// BreakpointSM represents small screens (40-60 columns).
BreakpointSM
// BreakpointMD represents medium screens (60-80 columns).
BreakpointMD
// BreakpointLG represents large screens (80-100 columns).
BreakpointLG
// BreakpointXL represents extra large screens (>= 100 columns).
BreakpointXL
)

type ConfirmationModel

ConfirmationModel is a reusable confirmation dialog component based on huh.Confirm. It provides a styled yes/no dialog with keyboard shortcuts.

Example usage as a standalone dialog:

confirmed, err := ui.PromptConfirmation("Delete file?", "Are you sure?", theme)
if err != nil {
return err
}
if confirmed {
// perform action
}

Example usage embedded in another Bubble Tea model:

// In your model struct:
type myModel struct {
confirmMode bool
confirm *ui.ConfirmationModel
}
// To show the dialog:
confirmModel := ui.NewConfirmationModel("Delete?", "Are you sure?", theme)
m.confirmMode = true
m.confirm = &confirmModel
return m, confirmModel.Init()
// In Update method:
if m.confirmMode {
updated, cmd := m.confirm.Update(msg)
if updatedConfirm, ok := updated.(ui.ConfirmationModel); ok {
m.confirm = &updatedConfirm
if cmd != nil {
if _, isQuit := cmd().(tea.QuitMsg); isQuit {
confirmed := m.confirm.ChoiceValue()
m.confirmMode = false
// handle result
}
}
}
return m, cmd
}
// In View method:
if m.confirmMode && m.confirm != nil {
return m.confirm.View()
}
type ConfirmationModel struct {
// contains filtered or unexported fields
}

func NewConfirmationModel

func NewConfirmationModel(title, prompt string, theme Theme) ConfirmationModel

NewConfirmationModel creates a new confirmation dialog

func (ConfirmationModel) ChoiceValue

func (m ConfirmationModel) ChoiceValue() bool

ChoiceValue returns the user’s choice

func (ConfirmationModel) Init

func (m ConfirmationModel) Init() tea.Cmd

Init initializes the confirmation dialog

func (ConfirmationModel) Update

func (m ConfirmationModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Update handles messages for the confirmation dialog

func (ConfirmationModel) View

func (m ConfirmationModel) View() string

View renders the confirmation dialog

type FrameSizeOptions

FrameSizeOptions configures shared list sizing inside framed views.

type FrameSizeOptions struct {
HorizontalInset int
VerticalInset int
MinWidth int
MinHeight int
}

func FrameSizeDefaults

func FrameSizeDefaults() FrameSizeOptions

FrameSizeDefaults returns base inset values for framed views.

type ItemWithMetadata

ItemWithMetadata is an optional interface that list items can implement to provide a third row of metadata under the description. Note: Currently items should embed metadata in Description() directly. This interface is reserved for future use when custom delegate rendering is implemented.

type ItemWithMetadata interface {
list.Item
Metadata() string
}

type ListDelegateOptions

ListDelegateOptions configures shared list presentation settings.

type ListDelegateOptions struct {
Height int
PaddingLeft int
SelectedPaddingLeft int
Spacing string // "compact", "tight", or "space" (default)
ShowMetadata bool // Enable metadata row support
MetadataIndent int // Indentation for metadata row (default: 1)
}

type ListHelpOptions

type ListHelpOptions struct {
IncludeFilter bool
IncludePaging bool
IncludeQuit bool
}

type ResponsiveManager

ResponsiveManager tracks view width and provides responsive utilities.

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

func NewResponsiveManager

func NewResponsiveManager(width int) *ResponsiveManager

NewResponsiveManager creates a new responsive manager with the given width.

func (*ResponsiveManager) AdaptiveFrameStyle

func (rm *ResponsiveManager) AdaptiveFrameStyle(theme Theme) lipgloss.Style

AdaptiveFrameStyle returns a frame style that adapts based on breakpoint. XS: No padding, no margin, no border SM: Padding only, no margin, no border MD+: Full styling with padding, margin, and border

func (*ResponsiveManager) Breakpoint

func (rm *ResponsiveManager) Breakpoint() Breakpoint

Breakpoint returns the current breakpoint category.

func (*ResponsiveManager) GetContentInsets

func (rm *ResponsiveManager) GetContentInsets() (horizontal, vertical int)

GetContentInsets returns the horizontal and vertical insets for content based on the current breakpoint. These values account for padding, margins, and borders applied by AdaptiveFrameStyle.

func (*ResponsiveManager) GetHelpHeight

func (rm *ResponsiveManager) GetHelpHeight() int

GetHelpHeight returns the recommended height for help text based on breakpoint.

func (*ResponsiveManager) GetListDimensions

func (rm *ResponsiveManager) GetListDimensions(availableWidth, availableHeight int) (width, height int)

GetListDimensions returns responsive width and height for a list component. It accounts for frame insets and provides sensible defaults based on breakpoint.

func (*ResponsiveManager) IsAtLeast

func (rm *ResponsiveManager) IsAtLeast(bp Breakpoint) bool

IsAtLeast checks if the current breakpoint is at least the given size.

func (*ResponsiveManager) IsAtMost

func (rm *ResponsiveManager) IsAtMost(bp Breakpoint) bool

IsAtMost checks if the current breakpoint is at most the given size.

func (*ResponsiveManager) MaxContentWidth

func (rm *ResponsiveManager) MaxContentWidth() int

MaxContentWidth returns the maximum usable content width accounting for padding/borders.

func (*ResponsiveManager) SetWidth

func (rm *ResponsiveManager) SetWidth(width int)

SetWidth updates the tracked width and recalculates the breakpoint.

func (*ResponsiveManager) ShouldShowBorders

func (rm *ResponsiveManager) ShouldShowBorders() bool

ShouldShowBorders returns true if borders should be rendered (MD or larger).

func (*ResponsiveManager) ShouldShowFullHelp

func (rm *ResponsiveManager) ShouldShowFullHelp() bool

ShouldShowFullHelp returns true if there’s enough space to show full help.

func (*ResponsiveManager) Width

func (rm *ResponsiveManager) Width() int

Width returns the current tracked width.

type Theme

Theme holds configurable colors for UI output.

type Theme struct {
Headings lipgloss.Color
Primary lipgloss.Color
Secondary lipgloss.Color
Text lipgloss.Color
TextHighlight lipgloss.Color
DescriptionHighlight lipgloss.Color
Tags lipgloss.Color
Flags lipgloss.Color
Muted lipgloss.Color
Border lipgloss.Color
}

func ThemeFromConfig

func ThemeFromConfig(cfg domain.Config) Theme

ThemeFromConfig builds a theme with safe fallbacks.

Source

See internal/ui/ for implementation details.