# huh: Build Interactive Terminal Forms and Prompts in Go

This repository profile is provided by osrepos.com, an open source repository discovery platform.

Source: osrepos.com
Repository profile: https://osrepos.com/repo/charmbracelet-huh
Generated for open source discovery and AI-assisted research.

`huh` is a simple yet powerful Go library from Charmbracelet designed for creating interactive forms and prompts directly within the terminal. It offers a wide range of field types, including text inputs, multi-selects, and confirmations, all easily configurable. The library also boasts features like accessibility support, customizable themes, and seamless integration with Bubble Tea applications, making it an excellent choice for enhancing command-line interfaces.

GitHub: https://github.com/charmbracelet/huh
OSRepos URL: https://osrepos.com/repo/charmbracelet-huh

## Summary

`huh` is a simple yet powerful Go library from Charmbracelet designed for creating interactive forms and prompts directly within the terminal. It offers a wide range of field types, including text inputs, multi-selects, and confirmations, all easily configurable. The library also boasts features like accessibility support, customizable themes, and seamless integration with Bubble Tea applications, making it an excellent choice for enhancing command-line interfaces.

## Topics

- Go
- CLI
- Terminal UI
- Forms
- Prompts
- Interactive
- Charmbracelet

## Repository Information

Last analyzed by OSRepos: Fri Mar 06 2026 09:21:18 GMT+0000 (Western European Standard Time)
Detail views: 2
GitHub clicks: 3

## Safety Notice

OSRepos shares public repositories for knowledge and discovery only. Review source code, dependencies, licenses, and security implications before running or installing anything.

## Content

## Introduction

`huh` is a robust and user-friendly Go library developed by Charmbracelet, specifically engineered for building interactive forms and prompts within the terminal. It empowers developers to create engaging command-line interfaces with a variety of input fields, making CLI applications more dynamic and user-friendly. Whether you need to gather simple text input, allow users to select from a list, or confirm actions, `huh` provides an elegant solution.

Key features of `huh` include:
*   A comprehensive set of field types: `Input`, `Text`, `Select`, `MultiSelect`, and `Confirm`.
*   Support for multi-page forms using groups.
*   Built-in validation for fields.
*   An accessible mode for screen readers.
*   Customizable themes to match your application's aesthetic.
*   Seamless integration with Charmbracelet's `Bubble Tea` framework.
*   Dynamic forms that adapt based on user input.

## Installation

Getting started with `huh` is straightforward. You can add it to your Go project using the standard `go get` command:

bash
go get github.com/charmbracelet/huh


## Examples

`huh` makes it easy to create both simple prompts and complex multi-page forms. Here's a quick example demonstrating a single input field:

go
package main

import (
	"fmt"
	"log"

	"github.com/charmbracelet/huh"
)

func main() {
	var name string

	err := huh.NewInput().
		Title("What’s your name?").
		Value(&name).
		Run() // this is blocking...

	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("Hey, %s!\n", name)
}


For more elaborate scenarios, `huh` allows you to construct multi-group forms with various field types. Below is an excerpt from a burger ordering form, showcasing `Select`, `MultiSelect`, `Input`, `Text`, and `Confirm` fields:

go
package main

import (
	"errors"
	"fmt"
	"log"

	"github.com/charmbracelet/huh"
)

var (
	burger       string
	toppings     []string
	sauceLevel   int
	name         string
	instructions string
	discount     bool
)

func main() {
	form := huh.NewForm(
		huh.NewGroup(
			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),

			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).
				Value(&toppings),

			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),
		),

		huh.NewGroup(
			huh.NewInput().
				Title("What’s your name?").
				Value(&name).
				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),
		),
	)

	err := form.Run()
	if err != nil {
		log.Fatal(err)
	}

	if !discount {
		fmt.Println("What? You didn’t take the discount?!")
	}
}


`huh` also supports dynamic forms, where fields can change based on previous inputs, and an accessible mode for improved usability with screen readers.

## Why Use `huh`?

`huh` stands out for several reasons, making it an excellent choice for developers looking to enhance their CLI applications:

*   **Simplicity and Power**: It offers a clean and intuitive API that allows for the rapid development of complex interactive forms.
*   **Rich User Experience**: By bringing interactive forms to the terminal, `huh` elevates the user experience of command-line tools beyond simple text prompts.
*   **Flexibility**: With a variety of field types, validation capabilities, and dynamic form features, `huh` can adapt to almost any input requirement.
*   **Accessibility**: The dedicated accessible mode ensures that your CLI applications are usable by a wider audience, including those who rely on screen readers.
*   **Customization**: Theming options allow you to tailor the look and feel of your forms to perfectly match your brand or application's style.
*   **Bubble Tea Integration**: For those building more extensive Terminal User Interface (TUI) applications with `Bubble Tea`, `huh` integrates seamlessly, acting as a `tea.Model` for advanced control.

## Links

*   **GitHub Repository**: [https://github.com/charmbracelet/huh](https://github.com/charmbracelet/huh){:target="_blank"}
*   **Go Documentation**: [https://pkg.go.dev/github.com/charmbracelet/huh?tab=doc](https://pkg.go.dev/github.com/charmbracelet/huh?tab=doc){:target="_blank"}
*   **Charmbracelet**: [https://charm.sh](https://charm.sh){:target="_blank"}