Documentation
¶
Overview ¶
Package input provides a single-line text input wrapped in a pane — a theme-styled, bordered text field with a title slot on the border.
Like every other tuilib component (filter, list, …), input owns its own pane: View() returns the bordered render. Don't wrap an input in another pane — set Options.Title to put the label on the border instead.
Use input as the building block for any text-entry need:
in := input.New(theme.Dark().Input())
in.SetTitle("Name")
// in your screen's Update: in, cmd = in.Update(msg)
// in your screen's View: string := in.View()
Reach for pkg/filter when you want the same input wired with the "/-to-focus, enter-commits, esc-clears" key behavior.
Index ¶
- type Model
- func (m *Model) Blur()
- func (m *Model) Focus() tea.Cmd
- func (m Model) Focused() bool
- func (m Model) Help() []key.Binding
- func (m Model) Init() tea.Cmd
- func (m *Model) Reset()
- func (m *Model) SetActiveColor(c lipgloss.TerminalColor)
- func (m *Model) SetCursorColor(c lipgloss.TerminalColor)
- func (m *Model) SetInactiveColor(c lipgloss.TerminalColor)
- func (m *Model) SetPlaceholderStyle(s lipgloss.Style)
- func (m *Model) SetTextStyle(s lipgloss.Style)
- func (m *Model) SetTitle(s string)
- func (m *Model) SetValue(s string)
- func (m *Model) SetWidth(w int)
- func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)
- func (m Model) Value() string
- func (m Model) View() string
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is the input's exported state. Focus state lives on both the embedded textinput (so keys route correctly) and the pane (so the border color reflects focus) — toggle them together via Focus/Blur.
func New ¶
New constructs an input. The cursor does not blink until Focus is called and its returned tea.Cmd is propagated.
func (*Model) Focus ¶
Focus grabs focus and returns the cursor-blink command. Always propagate the cmd — without it the cursor won't blink.
func (Model) Help ¶
Help returns the keys this input "owns" — there are no special shortcuts (typing is implied), so the slice is empty. Kept for interface symmetry with other components.
func (*Model) SetActiveColor ¶
func (m *Model) SetActiveColor(c lipgloss.TerminalColor)
SetActiveColor updates the border color used when focused.
func (*Model) SetCursorColor ¶
func (m *Model) SetCursorColor(c lipgloss.TerminalColor)
SetCursorColor updates the foreground color of the blinking cursor.
func (*Model) SetInactiveColor ¶
func (m *Model) SetInactiveColor(c lipgloss.TerminalColor)
SetInactiveColor updates the border color used when unfocused.
func (*Model) SetPlaceholderStyle ¶
SetPlaceholderStyle updates the rendered style of placeholder text.
func (*Model) SetTextStyle ¶
SetTextStyle updates the rendered style of typed text. Useful when reacting to a theme swap without rebuilding the model.
type Options ¶
type Options struct {
// Width sets the pane's outer width. Height is fixed at 3.
Width int
// Title sits on the top border of the pane. Defaults to "input" — set it
// to the field's label (e.g. "Name", "Email").
Title string
// Placeholder shows when the input is empty.
Placeholder string
// Initial pre-fills the value.
Initial string
// Prompt is rendered inline before the cursor inside the input. Defaults
// to "" — input is the bare-text variant; use pkg/filter when you want
// a prompt glyph.
Prompt string
// CharLimit caps input length. Defaults to 0 (unlimited).
CharLimit int
// Text-input styling.
PromptStyle lipgloss.Style
TextStyle lipgloss.Style
PlaceholderStyle lipgloss.Style
CursorColor lipgloss.TerminalColor
// Pane pass-throughs. Unset fields fall back to NormalBorder both states
// and SlotBracketsNone so the input reads as a plain bordered field.
ActiveColor lipgloss.TerminalColor
InactiveColor lipgloss.TerminalColor
ActiveBorder lipgloss.Border
InactiveBorder lipgloss.Border
SlotBrackets pane.SlotBracketStyle
}
Options configures a new input. Zero-value fields fall back to sensible defaults so a caller can `input.New(input.Options{})` and get a working (un-themed) input. Mutate the typed-text styles via the *Style fields and the surrounding border via the pane pass-throughs.