### Initialize a new FilePicker Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/filepicker.md Creates a new FilePicker instance and configures it with a title, starting directory, and a pointer to store the selected path. ```go var selectedPath string field := huh.NewFilePicker(). Title("Choose a file"). CurrentDirectory("."). Value(&selectedPath) ``` -------------------------------- ### Configure a MultiSelect field Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/multiselect.md Example showing how to initialize a MultiSelect field with options and bind it to a slice variable. ```go var toppings []string field := huh.NewMultiSelect[string](). Title("Select toppings"). Options( huh.NewOption("Lettuce", "lettuce"), huh.NewOption("Tomato", "tomato"), huh.NewOption("Cheese", "cheese"), ). Value(&toppings) ``` -------------------------------- ### FilePicker.CurrentDirectory Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/filepicker.md Sets the starting directory for browsing. ```APIDOC ## FilePicker.CurrentDirectory ### Description Sets the starting directory for browsing. ### Signature `func (f *FilePicker) CurrentDirectory(directory string) *FilePicker` ### Parameters - **directory** (string) - Required - Directory path (Default: current dir) ### Returns - `*FilePicker` - The field instance for chaining ### Example `field.CurrentDirectory("/home/user/documents")` ``` -------------------------------- ### FilePicker.Picking Method Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/filepicker.md Configures whether the file picker starts in picking mode. ```go func (f *FilePicker) Picking(v bool) *FilePicker ``` -------------------------------- ### Use ValidateOneOf Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/errors.md Example of using the ValidateOneOf helper. ```go field := huh.NewInput(). Title("Choose"). Validate(huh.ValidateOneOf("yes", "no", "maybe")) ``` -------------------------------- ### Configure Custom Value Accessors Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/configuration.md Implement custom storage types by defining Get and Set methods to interface with field values. ```go // Default pointer accessor var value string field.Value(&value) // Custom accessor type customStorage struct { data map[string]string } func (cs customStorage) Get() string { return cs.data["key"] } func (cs customStorage) Set(v string) { cs.data["key"] = v } field.Accessor(customStorage{...}) ``` -------------------------------- ### Update Go Dependencies for Huh v2 Source: https://github.com/charmbracelet/huh/blob/main/UPGRADE_GUIDE_V2.md Use 'go get' to update your go.mod file with the latest versions of Huh and related Charm libraries. ```bash go get charm.land/huh/v2@latest go get charm.land/bubbletea/v2@latest go get charm.land/lipgloss/v2@latest go get charm.land/bubbles/v2@latest ``` -------------------------------- ### Initialize Note Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/configuration.md Create a new Note instance for displaying information. ```go note := huh.NewNote() ``` -------------------------------- ### Create a basic form Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/README.md Initializes a form with multiple groups and fields, then executes it. ```go var name, email string var subscribe bool form := huh.NewForm( huh.NewGroup( huh.NewInput().Title("Name").Value(&name), huh.NewInput().Title("Email").Value(&email), ), huh.NewGroup( huh.NewConfirm().Title("Subscribe?").Value(&subscribe), ), ) if err := form.Run(); err != nil { log.Fatal(err) } ``` -------------------------------- ### Initialize Input Field Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/configuration.md Create a new input field instance. ```go input := huh.NewInput() ``` -------------------------------- ### Select.Filtering Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/select.md Sets whether the field starts in filtering mode. ```APIDOC ## Select.Filtering ### Description Sets whether the field starts in filtering mode. ### Signature `func (s *Select[T]) Filtering(filtering bool) *Select[T]` ### Parameters - **filtering** (bool) - Required - Start in filter mode (Default: false) ### Returns - `*Select[T]` - The field instance for chaining ``` -------------------------------- ### Initialize FilePicker Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/configuration.md Create a new FilePicker instance for selecting files or directories. ```go picker := huh.NewFilePicker() ``` -------------------------------- ### Create a multi-step wizard Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/README.md Initialize and run a form containing multiple groups, each representing a step in the wizard. ```go form := huh.NewForm( huh.NewGroup(field1, field2), huh.NewGroup(field3, field4), ) form.Run() ``` -------------------------------- ### Get Validation Error Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/text.md Retrieves the current validation error associated with the field, if one exists. ```go func (t *Text) Error() error ``` -------------------------------- ### Configure Form Help Visibility Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/form.md Sets whether to show help text with key bindings. Defaults to true. ```go func (f *Form) WithShowHelp(v bool) *Form ``` -------------------------------- ### Initialize a new Text field Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/text.md Creates a new text input instance with default settings. ```go func NewText() *Text ``` ```go var bio string field := huh.NewText(). Title("Tell us about yourself"). Lines(10). Value(&bio) ``` -------------------------------- ### Initialize a new Spinner Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/spinner.md Creates a new spinner instance with default settings and executes an action. ```go func New() *Spinner ``` ```go spinner := spinner.New(). Title("Processing..."). Action(func() { // Do work here time.Sleep(2 * time.Second) }). Run() ``` -------------------------------- ### Implementing Typed Accessors Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/accessor.md Custom accessors must implement Get and Set methods matching the field's generic type. ```go // String accessor for Input field type MyStringAccessor struct{} func (ma MyStringAccessor) Get() string { ... } func (ma MyStringAccessor) Set(value string) { ... } field := huh.NewInput().Accessor(MyStringAccessor{}) // Integer accessor for Select field type MyIntAccessor struct{} func (ma MyIntAccessor) Get() int { ... } func (ma MyIntAccessor) Set(value int) { ... } field := huh.NewSelect[int]().Accessor(MyIntAccessor{}) // Slice accessor for MultiSelect field type MySliceAccessor struct{} func (ma MySliceAccessor) Get() []string { ... } func (ma MySliceAccessor) Set(value []string) { ... } field := huh.NewMultiSelect[string]().Accessor(MySliceAccessor{}) ``` -------------------------------- ### Import and initialize Huh components Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/README.md Import the main package and the spinner subpackage to access form components and terminal spinners. ```go import "charm.land/huh/v2" // Main components form := huh.NewForm(...) input := huh.NewInput() select := huh.NewSelect[string]() // ... // Spinner subpackage import "charm.land/huh/v2/spinner" spinner.New().Run() ``` -------------------------------- ### Get Field Width with Width() Method Source: https://github.com/charmbracelet/huh/blob/main/UPGRADE_GUIDE_V2.md Select and MultiSelect fields now provide a Width() method to retrieve the field's current width. ```go width := multiSelect.Width() ``` -------------------------------- ### Initialize a new Note field Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/note.md Creates a new instance of a Note field with default settings. ```go field := huh.NewNote(). Title("Important Information"). Description("This is a note that displays information to the user.") ``` -------------------------------- ### Create a new option Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/option.md Instantiate an Option with a display key and an underlying value. ```go opt := huh.NewOption("New York", "NY") opt2 := huh.NewOption("Male", 1) ``` -------------------------------- ### Run the form Source: https://github.com/charmbracelet/huh/blob/main/README.md Execute the form and handle potential errors. ```go err := form.Run() if err != nil { log.Fatal(err) } ``` -------------------------------- ### Execute the form Source: https://github.com/charmbracelet/huh/blob/main/README.md Run the configured form and handle potential errors or post-submission logic. ```go err := form.Run() if err != nil { log.Fatal(err) } if !discount { fmt.Println("What? You didn’t take the discount?!") } ``` -------------------------------- ### Initialize Spinner Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/configuration.md Create a new Spinner instance for indicating background tasks. ```go spinner := spinner.New() ``` -------------------------------- ### Initialize Group Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/configuration.md Create a new Group instance to organize form fields. ```go group := huh.NewGroup(fields...) ``` -------------------------------- ### FilePicker.ShowSize Method Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/filepicker.md Configures the display of file sizes in the picker. ```go func (f *FilePicker) ShowSize(v bool) *FilePicker ``` -------------------------------- ### Import Huh Packages Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/README.md Standard import paths for the main Huh package and the spinner subpackage. ```go import "charm.land/huh/v2" ``` ```go import "charm.land/huh/v2/spinner" ``` -------------------------------- ### Run Spinner with Action or Context Source: https://github.com/charmbracelet/huh/blob/main/README.md Demonstrates two ways to run a spinner: using an action function or a context for lifecycle management. ```go err := spinner.New(). Title("Making your burger..."). Action(makeBurger). Run() fmt.Println("Order up!") ``` ```go go makeBurger() err := spinner.New(). Type(spinner.Line). Title("Making your burger..."). Context(ctx). Run() fmt.Println("Order up!") ``` -------------------------------- ### Initialize a new Form Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/form.md Creates a new form instance by passing one or more groups containing form fields. ```go form := huh.NewForm( huh.NewGroup( huh.NewInput().Title("Name").Value(&name), ), huh.NewGroup( huh.NewConfirm().Title("Confirm?").Value(&confirm), ), ) ``` -------------------------------- ### Create a single-page form Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/README.md Initialize and run a form containing a single group of fields. ```go form := huh.NewForm(huh.NewGroup(fields...)) form.Run() ``` -------------------------------- ### Form.WithShowHelp Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/form.md Configures whether the form displays help text containing key bindings. ```APIDOC ## func (f *Form) WithShowHelp(v bool) *Form ### Description Sets whether to show help text with key bindings. ### Parameters - **v** (bool) - Required - Show help keybindings (Default: true) ### Returns - ***Form** - The form instance for chaining ``` -------------------------------- ### New() Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/spinner.md Creates a new instance of a Spinner with default settings. ```APIDOC ## func New() ### Description Creates a new spinner with default settings (Dot animation, "Loading..." title). ### Returns *Spinner - A new spinner instance. ``` -------------------------------- ### Initialize a new Confirm field Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/confirm.md Creates a new confirm field instance with default labels. ```go func NewConfirm() *Confirm ``` ```go var agreeToTerms bool field := huh.NewConfirm(). Title("Do you agree to the terms?"). Value(&agreeToTerms) ``` -------------------------------- ### Create a Text field Source: https://github.com/charmbracelet/huh/blob/main/README.md Prompt the user for multiple lines of text. ```go huh.NewText(). Title("Tell me a story."). Validate(checkForPlagiarism). Value(&story) ``` -------------------------------- ### Initialize a new Input field Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/input.md Creates a new input instance using the huh.NewInput constructor. ```go input := huh.NewInput(). Title("What's your name?"). Value(&name) ``` -------------------------------- ### Configure form groups and fields Source: https://github.com/charmbracelet/huh/blob/main/README.md Construct a form using groups and fields, binding them to variables and applying validation logic. ```go form := huh.NewForm( huh.NewGroup( // Ask the user for a base burger and toppings. huh.NewSelect[string](). Title("Choose your burger"). Options( huh.NewOption("Charmburger Classic", "classic"), huh.NewOption("Chickwich", "chickwich"), huh.NewOption("Fishburger", "fishburger"), huh.NewOption("Charmpossible™ Burger", "charmpossible"), ). Value(&burger), // store the chosen option in the "burger" variable // Let the user select multiple toppings. huh.NewMultiSelect[string](). Title("Toppings"). Options( huh.NewOption("Lettuce", "lettuce").Selected(true), huh.NewOption("Tomatoes", "tomatoes").Selected(true), huh.NewOption("Jalapeños", "jalapeños"), huh.NewOption("Cheese", "cheese"), huh.NewOption("Vegan Cheese", "vegan cheese"), huh.NewOption("Nutella", "nutella"), ). Limit(4). // there’s a 4 topping limit! Value(&toppings), // Option values in selects and multi selects can be any type you // want. We’ve been recording strings above, but here we’ll store // answers as integers. Note the generic "[int]" directive below. huh.NewSelect[int](). Title("How much Charm Sauce do you want?"). Options( huh.NewOption("None", 0), huh.NewOption("A little", 1), huh.NewOption("A lot", 2), ). Value(&sauceLevel), ), // Gather some final details about the order. huh.NewGroup( huh.NewInput(). Title("What’s your name?"). Value(&name). // Validating fields is easy. The form will mark erroneous fields // and display error messages accordingly. Validate(func(str string) error { if str == "Frank" { return errors.New("Sorry, we don’t serve customers named Frank.") } return nil }), huh.NewText(). Title("Special Instructions"). CharLimit(400). Value(&instructions), huh.NewConfirm(). Title("Would you like 15% off?"). Value(&discount), ), ) ``` -------------------------------- ### Define a custom theme Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/README.md Creates a custom theme by extending the base styles using ThemeFunc. ```go customTheme := huh.ThemeFunc(func(isDark bool) *huh.Styles { styles := huh.ThemeBase(isDark) // Customize styles return styles }) form.WithTheme(customTheme) ``` -------------------------------- ### Configure Allowed File Types Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/filepicker.md Sets file extensions that are allowed, causing other files to appear disabled. ```go func (f *FilePicker) AllowedTypes(types []string) *FilePicker ``` ```go field.AllowedTypes([]string{".txt", ".md", ".go"}) ``` -------------------------------- ### Set a static description Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/note.md Configures the static description text displayed below the title. ```go field.Description("This is a longer description about the note.") ``` -------------------------------- ### Create an Input field Source: https://github.com/charmbracelet/huh/blob/main/README.md Prompt the user for a single line of text. ```go huh.NewInput(). Title("What’s for lunch?"). Prompt("?"). Validate(isFood). Value(&lunch) ``` -------------------------------- ### Select.Options Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/select.md Sets a static list of options for the user to choose from. ```APIDOC ## Select.Options ### Signature `func (s *Select[T]) Options(options ...Option[T]) *Select[T]` ### Description Sets the static list of options to choose from. ### Parameters - **options** (...Option[T]) - Optional - Variable number of options ### Returns - ***Select[T]** - The field instance for chaining ### Example ```go field.Options( huh.NewOption("Option A", valueA), huh.NewOption("Option B", valueB), huh.NewOption("Option C", valueC), ) ``` ``` -------------------------------- ### Group.WithShowHelp Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/group.md Sets whether to show key binding help for the group. ```APIDOC ## func (g *Group) WithShowHelp(show bool) *Group ### Description Sets whether to show key binding help for the group. ### Parameters - **show** (bool) - Required - Show help text (Default: true) ### Returns - *Group - The group instance for chaining ``` -------------------------------- ### Update Import Paths from Huh v1 to v2 Source: https://github.com/charmbracelet/huh/blob/main/UPGRADE_GUIDE_V2.md Change your import paths to use the 'charm.land' vanity domain with the '/v2' suffix for Huh and related libraries. ```go // Before import ( "github.com/charmbracelet/huh" "github.com/charmbracelet/huh/spinner" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" "github.com/charmbracelet/bubbles/key" ) // After import ( "charm.land/huh/v2" "charm.land/huh/v2/spinner" tea "charm.land/bubbletea/v2" "charm.land/lipgloss/v2" "charm.land/bubbles/v2/key" ) ``` -------------------------------- ### Configure Directory Selection Permission Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/filepicker.md Sets whether directories can be selected in the picker. ```go func (f *FilePicker) DirAllowed(v bool) *FilePicker ``` -------------------------------- ### Set Select Options Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/select.md Configures a static list of options for the select component. ```go func (s *Select[T]) Options(options ...Option[T]) *Select[T] ``` ```go field.Options( huh.NewOption("Option A", valueA), huh.NewOption("Option B", valueB), huh.NewOption("Option C", valueC), ) ``` -------------------------------- ### Integrate Huh Form into Bubble Tea Model Source: https://github.com/charmbracelet/huh/blob/main/README.md Shows how to embed a huh.Form as a tea.Model, implementing the standard Init, Update, and View methods. ```go type Model struct { form *huh.Form // huh.Form is just a tea.Model } func NewModel() Model { return Model{ form: huh.NewForm( huh.NewGroup( huh.NewSelect[string](). Key("class"). Options(huh.NewOptions("Warrior", "Mage", "Rogue")...). Title("Choose your class"), huh.NewSelect[int](). Key("level"). Options(huh.NewOptions(1, 20, 9999)...). Title("Choose your level"), ), ) } } func (m Model) Init() tea.Cmd { return m.form.Init() } func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { // ... form, cmd := m.form.Update(msg) if f, ok := form.(*huh.Form); ok { m.form = f } return m, cmd } func (m Model) View() string { if m.form.State == huh.StateCompleted { class := m.form.GetString("class") level := m.form.GetInt("level") return fmt.Sprintf("You selected: %s, Lvl. %d", class, level) } return m.form.View() } ``` -------------------------------- ### Set Select Height Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/select.md Configures the number of lines displayed in the options list. ```go func (s *Select[T]) Height(height int) *Select[T] ``` ```go field.Height(15) ``` -------------------------------- ### Apply built-in themes Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/configuration.md Lists available pre-defined themes for Huh forms. ```go huh.ThemeCharm() // Charm color scheme (fuchsia, green, red) huh.ThemeDracula() // Dracula color scheme huh.ThemeCatppuccin() // Catppuccin color scheme huh.ThemeBase16() // Base 16 color scheme huh.ThemeDefault() // Default light theme ``` -------------------------------- ### Catch and Configure ErrTimeout Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/errors.md Handle form timeouts and configure them using WithTimeout. ```go err := form.Run() if err == huh.ErrTimeout { fmt.Println("Form submission timed out") return } ``` ```go form.WithTimeout(30 * time.Second) if err := form.Run(); err == huh.ErrTimeout { log.Println("User took too long to complete form") } ``` -------------------------------- ### Configure File Selection Permission Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/filepicker.md Sets whether files can be selected in the picker. ```go func (f *FilePicker) FileAllowed(v bool) *FilePicker ``` -------------------------------- ### Create a Select field Source: https://github.com/charmbracelet/huh/blob/main/README.md Prompt the user to select a single option from a list. ```go huh.NewSelect[string](). Title("Pick a country."). Options( huh.NewOption("United States", "US"), huh.NewOption("Germany", "DE"), huh.NewOption("Brazil", "BR"), huh.NewOption("Canada", "CA"), ). Value(&country) ``` -------------------------------- ### Bubble Tea v2 Integration in Huh Field Methods Source: https://github.com/charmbracelet/huh/blob/main/UPGRADE_GUIDE_V2.md Field methods like Blur(), Focus(), and Init() now return 'charm.land/bubbletea/v2.Cmd' instead of 'tea.Cmd'. ```go // Field Methods: // Blur() tea.Cmd (now returns charm.land/bubbletea/v2.Cmd) // Focus() tea.Cmd (now returns charm.land/bubbletea/v2.Cmd) // Init() tea.Cmd (now returns charm.land/bubbletea/v2.Cmd) // Update(tea.Msg) (tea.Model, tea.Cmd) (now uses v2 types) ``` -------------------------------- ### Configure Confirm Buttons Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/confirm.md Set custom labels for affirmative and negative buttons using method chaining. ```go field.Affirmative("Accept").Negative("Decline") ``` ```go field.Negative("Reject") ``` -------------------------------- ### Set static input suggestions in Go Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/input.md Configures a list of static strings for autocomplete. Users can trigger suggestions using Ctrl+E. ```go input.Suggestions([]string{"gmail.com", "yahoo.com", "outlook.com"}) ``` -------------------------------- ### Run a single field prompt Source: https://github.com/charmbracelet/huh/blob/main/README.md Use the Run method as a shorthand for gathering quick and easy input from a single field. ```go var name string huh.NewInput(). Title("What’s your name?"). Value(&name). Run() // this is blocking... fmt.Printf("Hey, %s!\n", name) ``` -------------------------------- ### Use Correct Theme Signature with `isDark` Parameter Source: https://github.com/charmbracelet/huh/blob/main/UPGRADE_GUIDE_V2.md All built-in themes now require a boolean parameter to indicate if the theme is dark. Pass `true` or `false` accordingly. ```go // ✅ Correct form.WithTheme(huh.ThemeCharm(true)) // ❌ Wrong form.WithTheme(huh.ThemeCharm()) ``` -------------------------------- ### Bubble Tea v2 Integration in Huh Form Methods Source: https://github.com/charmbracelet/huh/blob/main/UPGRADE_GUIDE_V2.md Form methods like Init(), Update(), and WithProgramOptions() have been updated to use Bubble Tea v2 types. ```go // Form Methods: // Init() tea.Cmd (now returns charm.land/bubbletea/v2.Cmd) // Update(tea.Msg) (tea.Model, tea.Cmd) (now uses v2 types) // WithProgramOptions(...tea.ProgramOption) (now uses v2 types) ``` -------------------------------- ### FilePicker.ShowPermissions Method Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/filepicker.md Configures the display of file permissions in the picker. ```go func (f *FilePicker) ShowPermissions(v bool) *FilePicker ``` -------------------------------- ### Create a new Group in Go Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/group.md Initializes a new group instance with a variable number of fields. ```go group := huh.NewGroup( huh.NewInput().Title("Name").Value(&name), huh.NewInput().Title("Email").Value(&email), huh.NewConfirm().Title("Subscribe?").Value(&subscribe), ) ``` -------------------------------- ### Define form variables Source: https://github.com/charmbracelet/huh/blob/main/README.md Initialize the variables that will store user input from the form fields. ```go package main import "charm.land/huh/v2" var ( burger string toppings []string sauceLevel int name string instructions string discount bool ) ``` -------------------------------- ### Update Lip Gloss Style Import Path Source: https://github.com/charmbracelet/huh/blob/main/UPGRADE_GUIDE_V2.md Update the import path for Lip Gloss styles from v1 to v2. The API remains largely the same. ```go import "github.com/charmbracelet/lipgloss" style := lipgloss.NewStyle(). Foreground(lipgloss.Color("205")) ``` ```go import "charm.land/lipgloss/v2" style := lipgloss.NewStyle(). Foreground(lipgloss.Color("205")) ``` -------------------------------- ### FilePicker.ShowHidden Method Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/filepicker.md Configures the visibility of hidden files and directories. ```go func (f *FilePicker) ShowHidden(v bool) *FilePicker ``` ```go field.ShowHidden(true) ``` -------------------------------- ### Set Inline Display Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/confirm.md Configure whether confirmation buttons appear side-by-side or stacked. ```go field.Inline(true) // Buttons on same line ``` -------------------------------- ### Define TextKeyMap struct Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/types.md Configures key bindings for text and textarea input fields. ```go type TextKeyMap struct { Next key.Binding Prev key.Binding NewLine key.Binding Editor key.Binding Submit key.Binding } ``` -------------------------------- ### huh.NewConfirm Source: https://github.com/charmbracelet/huh/blob/main/README.md Creates a new confirmation prompt. ```APIDOC ## huh.NewConfirm() ### Description Prompts the user to confirm an action (Yes or No). ### Usage ```go huh.NewConfirm(). Title("Are you sure?"). Affirmative("Yes!"). Negative("No."). Value(&confirm) ``` ``` -------------------------------- ### Run Confirm component in Go Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/confirm.md Executes the confirmation prompt in standalone mode, blocking until the user makes a selection. ```go func (c *Confirm) Run() error ``` ```go var proceed bool if err := huh.NewConfirm(). Title("Continue?"). Value(&proceed). Run(); err != nil { log.Fatal(err) } ``` -------------------------------- ### Initialize Select Field Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/configuration.md Create a new select field instance with a generic type parameter. ```go select := huh.NewSelect[T]() ``` -------------------------------- ### Create multiple options Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/option.md Generate a slice of options from a list of values where the key and value are identical. ```go opts := huh.NewOptions("red", "green", "blue") // Creates options with key and value both set to the color string nums := huh.NewOptions(1, 2, 3, 4, 5) // Creates options for numbers ``` -------------------------------- ### Define form variables Source: https://github.com/charmbracelet/huh/blob/main/README.md Initialize variables to store user selections for the dynamic form. ```go var country string var state string ``` -------------------------------- ### Set Confirm Title Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/confirm.md Configures the static question text displayed for the confirmation component. ```go func (c *Confirm) Title(title string) *Confirm ``` ```go field.Title("Are you sure?") ``` -------------------------------- ### Note.Next Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/note.md Configures the visibility of the Next button. ```APIDOC ## Note.Next ### Description Sets whether to show a "Next" button. When enabled, the user must press the button to proceed. ### Parameters - **show** (bool) - Required - Show next button ### Returns - `*Note` - The field instance for chaining ``` -------------------------------- ### Configure Field Options Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/configuration.md Define options for select fields using individual option constructors or by expanding a slice of values. ```go field.Options( huh.NewOption("Label 1", value1).Selected(true), huh.NewOption("Label 2", value2), huh.NewOption("Label 3", value3), ) ``` ```go values := []string{"a", "b", "c"} field.Options(huh.NewOptions(values...)...) ``` -------------------------------- ### Set dynamic input suggestions in Go Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/input.md Configures a function to provide suggestions that update based on changes to bound values. ```go var prefix string input.SuggestionsFunc(func() []string { return fetchDomainSuggestions(prefix) }, &prefix) ``` -------------------------------- ### Set Confirm Description Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/confirm.md Configures the static description text displayed below the confirmation title. ```go func (c *Confirm) Description(description string) *Confirm ``` ```go field.Description("This action cannot be undone") ``` -------------------------------- ### Set FilePicker Current Directory Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/filepicker.md Defines the initial directory path for the file browser. ```go field.CurrentDirectory("/home/user/documents") ``` -------------------------------- ### Apply a theme to a form Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/README.md Configures form appearance using built-in themes and width settings. ```go form.WithTheme(huh.ThemeCharm()). WithWidth(100). Run() ``` -------------------------------- ### Enable accessible mode via environment variable Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/configuration.md Sets the ACCESSIBLE variable to enable screen reader compatibility. ```bash export ACCESSIBLE=1 ./myapp ``` -------------------------------- ### Set Text Placeholder Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/text.md Configures the placeholder text displayed when the input field is empty. ```go field.Placeholder("Enter text here...") ``` -------------------------------- ### Set a dynamic description Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/note.md Configures a description that updates when the binding value changes, useful for dynamic content like markdown. ```go var markdown string field.DescriptionFunc(func() string { return renderMarkdown(markdown) }, &markdown) ``` -------------------------------- ### Set a static title Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/note.md Configures the static title text displayed at the top of the note. ```go field.Title("Welcome") ``` -------------------------------- ### Select.Description Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/select.md Sets the static description displayed below the title. ```APIDOC ## func (s *Select[T]) Description(description string) *Select[T] ### Description Sets the static description displayed below the title. ### Parameters - **description** (string) - Required - Field description ### Returns - *Select[T] - The field instance for chaining ``` -------------------------------- ### Set Input prompt symbol Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/input.md Defines the string displayed before the input area, defaulting to '> '. ```go func (i *Input) Prompt(prompt string) *Input ``` ```go input.Prompt("? ") ``` -------------------------------- ### Check Charm Dependency Versions Source: https://github.com/charmbracelet/huh/blob/main/UPGRADE_GUIDE_V2.md Verify that all Charm dependencies are updated to v2 to resolve import cycle issues. Use `go list -m all` to check. ```bash go list -m all | grep charmbracelet go list -m all | grep charm.land ``` -------------------------------- ### NewForm Constructor Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/configuration.md Initializes a new form and configures it using method chaining. ```APIDOC ## NewForm(groups ...*Group) ### Description Creates a new form instance. Configuration is performed via method chaining using `With*` methods. ### Methods - **WithAccessible(bool)**: Enable accessible (text-only) mode. - **WithTheme(Theme)**: Set form styling theme. - **WithKeyMap(*KeyMap)**: Set custom key bindings. - **WithWidth(int)**: Set form width in characters. - **WithHeight(int)**: Set form height in lines. - **WithTimeout(time.Duration)**: Set form timeout duration. - **WithOutput(io.Writer)**: Set output destination. - **WithInput(io.Reader)**: Set input source. - **WithLayout(Layout)**: Set group layout strategy. - **WithShowHelp(bool)**: Toggle key binding help visibility. - **WithShowErrors(bool)**: Toggle validation error message visibility. - **WithProgramOptions(...tea.ProgramOption)**: Set Bubble Tea program options. - **WithViewHook(compat.ViewHook)**: Set view rendering hook. ``` -------------------------------- ### Spinner.WithTheme Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/spinner.md Sets the theme for the spinner styling. ```APIDOC ## Spinner.WithTheme ### Description Sets the theme for the spinner styling. ### Parameters - **theme** (Theme) - Required - Theme implementation (Default: ThemeDefault) ### Returns - *Spinner - The spinner instance for chaining ### Example ```go spinner.WithTheme(customTheme) ``` ``` -------------------------------- ### huh.NewInput Source: https://github.com/charmbracelet/huh/blob/main/README.md Creates a new single-line text input field. ```APIDOC ## huh.NewInput() ### Description Prompts the user for a single line of text. ### Usage ```go huh.NewInput(). Title("What’s for lunch?"). Prompt("?"). Validate(isFood). Value(&lunch) ``` ``` -------------------------------- ### Set MultiSelect Options Function Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/multiselect.md Configures a dynamic options provider that updates when the specified bindings change. ```go func (m *MultiSelect[T]) OptionsFunc(f func() []Option[T], bindings any) *MultiSelect[T] ``` ```go var category string field.OptionsFunc(func() []huh.Option[string] { opts := fetchItemsForCategory(category) return huh.NewOptions(opts...) }, &category) ``` -------------------------------- ### Create a Confirm field Source: https://github.com/charmbracelet/huh/blob/main/README.md Prompt the user to confirm an action with Yes or No options. ```go huh.NewConfirm(). Title("Are you sure?"). Affirmative("Yes!"). Negative("No."). Value(&confirm) ``` -------------------------------- ### NewOptions[T] Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/option.md Creates a slice of options from a list of values, using the string representation of each value as the display key. ```APIDOC ## func NewOptions[T comparable](values ...T) []Option[T] ### Description Creates options from a list of values. The display key is the string representation of each value. ### Parameters - **values** (...T) - Required - Variable number of values ### Returns - **[]Option[T]** - Slice of options ``` -------------------------------- ### Set Dynamic Confirm Description Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/confirm.md Configures a dynamic description that updates based on changes to the provided bindings. ```go func (c *Confirm) DescriptionFunc(f func() string, bindings any) *Confirm ``` -------------------------------- ### Execute Spinner Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/spinner.md Runs the spinner and blocks until the associated action completes. Returns an error if the action fails. ```go func (s *Spinner) Run() error ``` ```go err := spinner.New(). Title("Loading..."). Action(myFunction). Run() if err != nil { log.Fatal(err) } ``` -------------------------------- ### Initialize Select Field with NewSelect Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/select.md Creates a new select field instance for a specific comparable type, allowing for string or integer options. ```go // String options select := huh.NewSelect[string](). Title("Choose a color"). Options( huh.NewOption("Red", "red"), huh.NewOption("Blue", "blue"), ) // Integer options level := huh.NewSelect[int](). Title("Choose a level"). Options( huh.NewOption("Easy", 1), huh.NewOption("Hard", 3), ) ``` -------------------------------- ### Create a MultiSelect field Source: https://github.com/charmbracelet/huh/blob/main/README.md Prompt the user to select multiple options from a list with an optional limit. ```go huh.NewMultiSelect[string](). Options( huh.NewOption("Lettuce", "Lettuce").Selected(true), huh.NewOption("Tomatoes", "Tomatoes").Selected(true), huh.NewOption("Charm Sauce", "Charm Sauce"), huh.NewOption("Jalapeños", "Jalapeños"), huh.NewOption("Cheese", "Cheese"), huh.NewOption("Vegan Cheese", "Vegan Cheese"), huh.NewOption("Nutella", "Nutella"), ). Title("Toppings"). Limit(4). Value(&toppings) ``` -------------------------------- ### Set form layout strategy Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/configuration.md Configures how groups are displayed within the form. ```go form.WithLayout(huh.LayoutDefault) // One group at a time form.WithLayout(huh.LayoutStack) // All groups vertically form.WithLayout(huh.LayoutColumns(2)) // Groups in 2 columns form.WithLayout(huh.LayoutGrid(2, 3)) // Groups in 2x3 grid ``` -------------------------------- ### Define NoteKeyMap Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/types.md Defines the key bindings available for note fields. ```go type NoteKeyMap struct { Next key.Binding Prev key.Binding Submit key.Binding } ``` -------------------------------- ### Set a dynamic title Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/note.md Configures a title that updates automatically when the provided binding value changes. ```go var step int field.TitleFunc(func() string { return fmt.Sprintf("Step %d", step) }, &step) ``` -------------------------------- ### Set Spinner Theme Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/spinner.md Configures the visual theme for the spinner. Requires a valid Theme implementation. ```go spinner.WithTheme(customTheme) ``` -------------------------------- ### Input.Run Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/input.md Executes the input field in standalone mode. ```APIDOC ## Input.Run ### Description Runs the input field in standalone mode, blocking until submission. ### Signature `func (i *Input) Run() error` ### Returns - `error` - nil on successful entry, or error from validation/user abort ### Example ```go var name string huh.NewInput(). Title("Name?"). Value(&name). Run() ``` ``` -------------------------------- ### Define FilePickerKeyMap Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/types.md Defines the key bindings available for file picker fields. ```go type FilePickerKeyMap struct { Open key.Binding Close key.Binding GotoTop key.Binding GotoBottom key.Binding PageUp key.Binding PageDown key.Binding Back key.Binding Select key.Binding Up key.Binding Down key.Binding Prev key.Binding Next key.Binding Submit key.Binding } ``` -------------------------------- ### FilePicker.Run Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/filepicker.md Runs the field in standalone mode, blocking until a file or directory is selected. ```APIDOC ## FilePicker.Run ### Description Runs the field in standalone mode, blocking until a file/directory is selected. ### Signature `func (f *FilePicker) Run() error` ### Returns - `error` - nil on successful selection, or an error from validation or user abort ``` -------------------------------- ### Define FormStyles Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/types.md Defines the container styles for the entire form. ```go type FormStyles struct { Base lipgloss.Style } ``` -------------------------------- ### Correct Bubble Tea Import for v2 Source: https://github.com/charmbracelet/huh/blob/main/UPGRADE_GUIDE_V2.md Ensure the Bubble Tea import path is updated to v2 to prevent type mismatches with `tea.Model`, `tea.Msg`, or `tea.Cmd`. ```go import tea "charm.land/bubbletea/v2" // Make sure it's v2! ``` -------------------------------- ### FilePicker.ShowSize Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/filepicker.md Sets whether to display file sizes. ```APIDOC ## func (f *FilePicker) ShowSize(v bool) *FilePicker ### Description Sets whether to display file sizes. ### Parameters - **v** (bool) - Required - Show file sizes (Default: false) ### Returns - *FilePicker - The field instance for chaining ``` -------------------------------- ### NewForm Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/form.md Creates a new form instance with the provided groups and default settings. ```APIDOC ## func NewForm(groups ...*Group) *Form ### Description Creates a new form with the given groups and applies default themes and keybindings. ### Parameters - **groups** (...*Group) - Required - Variable number of groups to include in the form ### Returns - ***Form** - A new form instance initialized with default settings ### Example ```go form := huh.NewForm( huh.NewGroup( huh.NewInput().Title("Name").Value(&name), ), huh.NewGroup( huh.NewConfirm().Title("Confirm?").Value(&confirm), ), ) ``` ``` -------------------------------- ### Input.Description Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/input.md Sets the static description displayed below the title. ```APIDOC ## Input.Description ### Description Sets the static description displayed below the title. ### Signature `func (i *Input) Description(description string) *Input` ### Parameters - **description** (string) - Required - Field description ### Returns - `*Input` - The field instance for chaining ### Example ```go input.Description("Your full name as it appears in your passport") ``` ``` -------------------------------- ### Spinner.Run Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/spinner.md Executes the spinner and blocks until the associated action completes. ```APIDOC ## func (s *Spinner) Run() error ### Description Runs the spinner, blocks until the action completes. ### Returns - **error** - nil on successful completion, or an error from the action function. ### Example ```go err := spinner.New(). Title("Loading..."). Action(myFunction). Run() if err != nil { log.Fatal(err) } ``` ``` -------------------------------- ### Define SelectKeyMap struct Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/types.md Configures key bindings for select input fields. ```go type SelectKeyMap struct { Next key.Binding Prev key.Binding Up key.Binding Down key.Binding HalfPageUp key.Binding HalfPageDown key.Binding GotoTop key.Binding GotoBottom key.Binding Left key.Binding Right key.Binding Filter key.Binding SetFilter key.Binding ClearFilter key.Binding Submit key.Binding } ``` -------------------------------- ### Note Configuration Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/configuration.md Methods to configure the Note component. ```APIDOC ## Note Configuration ### Description Configures the display and navigation of the Note component. ### Methods - **Height(int)**: Sets the display height. - **Next(bool)**: Toggles the visibility of the next button. - **NextLabel(string)**: Sets the label for the next button. ``` -------------------------------- ### NewInput Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/input.md Creates a new instance of an Input field. ```APIDOC ## func NewInput() ### Description Creates a new input field with default settings. ### Returns *Input - A new input field instance. ``` -------------------------------- ### Select.Height Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/select.md Sets the display height of the options list. ```APIDOC ## Select.Height ### Description Sets the display height of the options list. ### Signature `func (s *Select[T]) Height(height int) *Select[T]` ### Parameters - **height** (int) - Required - Height in lines (Default: 10) ### Returns - `*Select[T]` - The field instance for chaining ### Example ```go field.Height(15) ``` ``` -------------------------------- ### huh.NewText Source: https://github.com/charmbracelet/huh/blob/main/README.md Creates a new multi-line text input field. ```APIDOC ## huh.NewText() ### Description Prompts the user for multiple lines of text. ### Usage ```go huh.NewText(). Title("Tell me a story."). Validate(checkForPlagiarism). Value(&story) ``` ``` -------------------------------- ### Set FilePicker Title Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/filepicker.md Configures the text displayed above the file picker component. ```go field.Title("Select a configuration file") ``` -------------------------------- ### FilePicker Configuration Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/configuration.md Methods to configure the FilePicker component. ```APIDOC ## FilePicker Configuration ### Description Configures the behavior and display of the FilePicker component. ### Methods - **CurrentDirectory(string)**: Sets the starting directory. - **Cursor(string)**: Sets the selection cursor symbol. - **Picking(bool)**: Sets whether to start in picking mode. - **ShowHidden(bool)**: Toggles visibility of hidden files. - **ShowSize(bool)**: Toggles visibility of file sizes. - **ShowPermissions(bool)**: Toggles visibility of file permissions. - **FileAllowed(bool)**: Toggles if files can be selected. - **DirAllowed(bool)**: Toggles if directories can be selected. - **AllowedTypes([]string)**: Sets allowed file extensions. - **Height(int)**: Sets the display height in lines. ``` -------------------------------- ### Set Select Field Description Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/select.md Configures the static description text displayed below the field title. ```go func (s *Select[T]) Description(description string) *Select[T] ``` -------------------------------- ### Form.WithTheme Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/form.md Sets the theme for the form, which applies to all groups and fields unless overridden. ```APIDOC ## func (f *Form) WithTheme(theme Theme) *Form ### Description Sets the theme for the form. Applies to all groups and fields unless they override it individually. ### Parameters - **theme** (Theme) - Required - Theme interface implementation ### Returns - ***Form** - The form instance for chaining ### Example ```go form.WithTheme(huh.ThemeCharm()) ``` ``` -------------------------------- ### Define ConfirmKeyMap Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/types.md Defines the key bindings available for confirm fields. ```go type ConfirmKeyMap struct { Next key.Binding Prev key.Binding Toggle key.Binding Submit key.Binding Accept key.Binding Reject key.Binding } ``` -------------------------------- ### Bind a string variable to Input Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/input.md Links a string pointer to the input field to store user input. ```go var name string input.Value(&name) ``` -------------------------------- ### Implement dynamic options Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/README.md Uses OptionsFunc to update select options based on the value of another field. ```go var country, state string form := huh.NewForm( huh.NewGroup( huh.NewSelect[string](). Title("Country"). Options(huh.NewOptions("USA", "Canada", "Mexico")...). Value(&country), huh.NewSelect[string](). Title("State"). OptionsFunc(func() []huh.Option[string] { states := fetchStates(country) return huh.NewOptions(states...) }, &country). Value(&state), ), ) ``` -------------------------------- ### Set an action with error handling Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/spinner.md Defines an action that accepts a context and returns an error, suitable for long-running tasks. ```go spinner.ActionWithErr(func(ctx context.Context) error { return myLongRunningTask(ctx) }) ``` -------------------------------- ### Initialize a new MultiSelect field Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/multiselect.md Creates a new instance of a MultiSelect field for a specific comparable type. ```go func NewMultiSelect[T comparable]() *MultiSelect[T] ``` -------------------------------- ### Form.WithLayout Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/form.md Sets the layout for displaying groups. ```APIDOC ## func (f *Form) WithLayout(layout Layout) *Form ### Description Sets the layout for displaying groups. Available layouts: `LayoutDefault`, `LayoutStack`, `LayoutColumns`, `LayoutGrid`. ### Parameters - **layout** (Layout) - Required - Layout implementation ### Returns - `*Form` - The form instance for chaining ### Example ```go form.WithLayout(huh.LayoutColumns(2)) ``` ``` -------------------------------- ### Run a Form in standalone mode Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/form.md Executes the form and blocks until completion, cancellation, or timeout. ```go if err := form.Run(); err == huh.ErrUserAborted { fmt.Println("Form cancelled") return } ``` -------------------------------- ### Key Bindings with Bubble Tea v2 in Huh Source: https://github.com/charmbracelet/huh/blob/main/UPGRADE_GUIDE_V2.md The KeyBinds() method now returns 'charm.land/bubbles/v2/key.Binding' to align with Bubble Tea v2. ```go // Key Bindings: // KeyBinds() []key.Binding (now returns charm.land/bubbles/v2/key.Binding) ``` -------------------------------- ### MultiSelect.Options Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/multiselect.md Sets the static list of options to choose from. ```APIDOC ## MultiSelect.Options ### Description Sets the static list of options to choose from. ### Parameters - **options** (...Option[T]) - Optional - Variable number of options ### Returns - ***MultiSelect[T]** - The field instance for chaining ### Example ```go field.Options( huh.NewOption("Item A", "a").Selected(true), huh.NewOption("Item B", "b"), huh.NewOption("Item C", "c"), ) ``` ``` -------------------------------- ### FilePicker.Description Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/filepicker.md Sets the description displayed below the title. ```APIDOC ## FilePicker.Description ### Description Sets the description displayed below the title. ### Signature `func (f *FilePicker) Description(description string) *FilePicker` ### Parameters - **description** (string) - Required - Field description ### Returns - `*FilePicker` - The field instance for chaining ``` -------------------------------- ### Set Select Description Function Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/select.md Defines a dynamic description that updates based on changes to the provided bindings. ```go func (s *Select[T]) DescriptionFunc(f func() string, bindings any) *Select[T] ``` -------------------------------- ### Set static text field description Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/text.md Configures a static description to display below the text input field title. ```go func (t *Text) Description(description string) *Text ``` -------------------------------- ### Select.Run Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/select.md Runs the field in standalone mode, blocking until a selection is made. ```APIDOC ## Select.Run ### Description Runs the field in standalone mode, blocking until a selection is made. ### Signature `func (s *Select[T]) Run() error` ### Returns - `error` - nil on successful selection, or error from validation/user abort ``` -------------------------------- ### Input.Suggestions Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/api-reference/input.md Sets static suggestions for autocomplete. User can press Ctrl+E to accept suggestions. ```APIDOC ## Input.Suggestions ### Signature `func (i *Input) Suggestions(suggestions []string) *Input` ### Description Sets static suggestions for autocomplete. User can press Ctrl+E to accept suggestions. ### Parameters - **suggestions** ([]string) - Required - List of suggestion strings ### Returns - *Input - The field instance for chaining ### Example ```go input.Suggestions([]string{"gmail.com", "yahoo.com", "outlook.com"}) ``` ``` -------------------------------- ### Define Layout Interface Source: https://github.com/charmbracelet/huh/blob/main/_autodocs/types.md Determines the arrangement and rendering logic for groups within a form. ```go type Layout interface { View(f *Form) string GroupWidth(f *Form, g *Group, w int) int } ```