huh: Build Interactive Terminal Forms and Prompts in Go

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

huh: Build Interactive Terminal Forms and Prompts in Go

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.

Repository Information

Analyzed by OSRepos on March 6, 2026

Topics

Click on any tag to explore related repositories

Use at your own risk

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of code from these repositories is the user's own responsibility. Always review the repository, source code, dependencies, licenses, and security implications before running or installing anything. OSRepos is not responsible for issues, damages, or losses resulting from third-party repositories.

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:

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:

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:

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?!\n")
	}
}

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

Related repositories

Similar repositories that may be relevant next.

GoBooks: A Curated List of Essential Golang Books for All Skill Levels

GoBooks: A Curated List of Essential Golang Books for All Skill Levels

July 20, 2026

GoBooks is a highly popular GitHub repository offering a meticulously curated collection of Golang books, catering to developers from beginners to advanced practitioners. It serves as a comprehensive resource for finding the right learning materials on topics like concurrency, performance, and system design, making it easier to navigate the vast Go ecosystem.

GoGolangBooks
Zero: The AI Coding Agent for Your Local Terminal

Zero: The AI Coding Agent for Your Local Terminal

July 6, 2026

Zero is an innovative AI coding agent designed for your local terminal, offering powerful capabilities to inspect repositories, edit files, run commands, and utilize browser/terminal helpers. It provides durable local sessions while giving users full control over the AI model and permission levels. This tool empowers developers with a customizable and secure AI assistant directly within their development environment.

aiai-agentcli
no-mistakes: AI-Driven Git Proxy for Flawless Pull Requests

no-mistakes: AI-Driven Git Proxy for Flawless Pull Requests

June 30, 2026

no-mistakes is an innovative Git proxy that streamlines the pull request workflow by ensuring code quality before it reaches your remote. It uses an AI-driven validation pipeline in a disposable worktree, automatically applying safe fixes and escalating complex issues for human review. This tool helps developers maintain clean, high-quality codebases and open perfect PRs effortlessly.

GitAIDeveloper Tools
Gogcli: Google Workspace Management from Your Terminal

Gogcli: Google Workspace Management from Your Terminal

June 24, 2026

Gogcli is a powerful command-line interface for Google Workspace, allowing users to manage Gmail, Calendar, Drive, Docs, Sheets, and many other services directly from their terminal. It is designed for both interactive use and robust automation, providing predictable output, agent safety features, and support for multiple accounts.

gcalgcontactsgdrive

Source repository

Open the original repository on GitHub.

13 counted GitHub visits

View on GitHub
OS
OSRepos

Analysis and discovery of open source repositories. Find interesting projects and follow their updates.

Monitor your website with YourWebsiteScore

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of third-party repository code is at your own risk. Always review source code, dependencies, licenses, and security implications before running anything.

© 2025 OSRepos. Built with Nuxt 3 and lots of ❤️