Documentation
¶
Overview ¶
Package uiform builds huh forms wired to Entire's standard theme and accessibility behavior. Centralises the Theme()+WithAccessible() recipe so picker UI stays consistent across callers.
Index ¶
Constants ¶
const SelectOptionIndent = " "
SelectOptionIndent is the blank prefix huh reserves for a select's cursor, so text put above the options (a column header in the field description) lines up with the option text instead of with the cursor.
It is the width of the SelectSelector string, "> ", which Theme inherits from ThemeBase16 and recolors without changing. A caller that overrides the selector string needs its own indent. TestSelectOptionIndentMatchesSelector pins the two together.
Variables ¶
This section is empty.
Functions ¶
func IsAccessibleMode ¶
func IsAccessibleMode() bool
IsAccessibleMode reports whether accessibility mode is enabled via the ACCESSIBLE environment variable. Set ACCESSIBLE=1 (or any non-empty value) to enable simpler prompts that work better with screen readers.
func Lenient ¶ added in v0.11.5
Lenient wraps a validator so that it passes while b reports the back key. A nil b wraps nothing.
func New ¶
New creates a huh form with the standard theme, switching to accessible mode when ACCESSIBLE is set. WithAccessible is only available on forms (not individual fields), so wrap confirmations and other prompts in a form to opt into accessibility.
func SingleLineMultiSelectHeight ¶ added in v0.10.3
SingleLineMultiSelectHeight reserves three rows for rendered field headers. Callers with multiline options or headers taller than three rows need a different height strategy. The form still clamps this on short terminals.
func Theme ¶
Theme returns Entire's standard huh theme: base16 (ANSI 0–15) colors so form prompts respect the user's terminal palette and stay consistent with the rest of the CLI's styling. Derived from huh.ThemeBase16 with a few overrides — magenta selection (pointer + chosen options); titles and unselected options use the terminal's default foreground so they invert with the background (dark text on light, light text on dark) like the checkbox bracket does.
Types ¶
type BackNav ¶ added in v0.11.5
type BackNav struct {
// contains filtered or unexported fields
}
BackNav keeps a paged form's "back" key working on a page whose field fails validation.
huh (v2.0.3) blurs the focused field and then asks the form for the previous page; the form refuses while the page has an error, and nothing refocuses the field it just blurred. The page then ignores every key: one invalid answer followed by Shift+Tab strands the user. BackNav watches each key on its way to the form, and a validator wrapped with Lenient passes while the key being handled is the back key — going back needs no valid answer, and the answer is checked again on the way forward.
Wire it with form.WithProgramOptions(nav.ProgramOption()). It has no effect in accessible mode, which has no back key.
func NewBackNav ¶ added in v0.11.5
func NewBackNav() *BackNav
NewBackNav returns a BackNav for huh's default "back" binding.
func (*BackNav) Going ¶ added in v0.11.5
Going reports whether the key being handled is the back key.
func (*BackNav) ProgramOption ¶ added in v0.11.5
func (b *BackNav) ProgramOption() tea.ProgramOption
ProgramOption installs the key watcher on the form's program.