uiform

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 7 Imported by: 0

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

View Source
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 New

func New(groups ...*huh.Group) *huh.Form

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 PromptYN

func PromptYN(ctx context.Context, question string, def bool) (bool, error)

PromptYN renders a Confirm form with the standard theme/accessibility behavior and returns the user's answer. On user cancellation (Ctrl+C or context.Canceled) returns (false, nil) so callers treat it as a "no"; on real form errors the error is returned wrapped.

func SingleLineMultiSelectHeight added in v0.10.3

func SingleLineMultiSelectHeight(optionCount int) int

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

func Theme() huh.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

This section is empty.

Jump to

Keyboard shortcuts

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