github charmbracelet/huh v2.0.0

latest release: v2.0.1
15 hours ago

Huh? v2?

We're thrilled to announce the second major release of Huh!

Note

We take API changes seriously, and we want to make the upgrade process as simple as possible.

❤️ Charm Land Import Path

We've updated our import paths to use vanity domains and use our domain to import Go packages.

// Before
import "github.com/charmbracelet/huh"

// After
import "charm.land/huh/v2"

🍵 Bubble Tea v2 & Lip Gloss v2

Huh v2 is built on the all-new Bubble Tea v2 and Lip Gloss v2, bringing all their improvements along for the ride:

  • The Cursed Renderer — optimized rendering built from the ground up on the ncurses algorithm
  • Better keyboard handling — progressive keyboard enhancements for modern terminals
  • Declarative views — no more fighting over terminal state
  • Built-in color downsampling — colors "just work" everywhere
  • And much more — see the Bubble Tea v2 release notes for the full picture

All these improvements come for free. Just upgrade and enjoy the performance and stability benefits.

🎨 Simpler Theming

Themes are now passed by value instead of pointer. This makes theme handling more straightforward and predictable.

// Before
form.WithTheme(huh.ThemeCharm())

// After
form.WithTheme(huh.ThemeCharm(false)) // false for light mode

All built-in themes now take a bool parameter to indicate whether the terminal has a dark background. Huh will automatically detect your terminal's background color, but you can also provide your own custom theme function:

type ThemeFunc func(isDark bool) *Styles

form.WithTheme(myCustomTheme)

🔍 View Hooks

Want to modify your form's view before it hits the screen? Now you can with WithViewHook:

form.WithViewHook(func(v tea.View) tea.View {
    // Modify the view properties
    v.AltScreen = true
    v.MouseMode = tea.MouseModeAllMotion
    return v
})

This is perfect for dynamically controlling terminal features, applying custom view transformations, or integrating Huh forms with larger Bubble Tea applications.

♿ Simplified Accessible Mode

The separate accessibility package is gone. Accessible mode is now built directly into Huh and controlled exclusively at the form level:

// Before - individual fields had their own accessible mode
input := huh.NewInput().
    Title("Name").
    WithAccessible(true)  // ❌ No longer exists on fields

select := huh.NewSelect[string]().
    Title("Pick one").
    Options(huh.NewOptions("A", "B", "C")...).
    WithAccessible(true)  // ❌ Removed from fields too

form := huh.NewForm(
    huh.NewGroup(input, select),
)

// After - only the form controls accessible mode
input := huh.NewInput().
    Title("Name")

select := huh.NewSelect[string]().
    Title("Pick one").
    Options(huh.NewOptions("A", "B", "C")...)

form := huh.NewForm(
    huh.NewGroup(input, select),
).WithAccessible(true)  // ✅ Set once at the form level

This makes accessible mode simpler and more consistent — one setting controls the entire form.

Tip

We recommend detecting accessible mode through environment variables or configuration options to let users control accessibility on their terms.

🗂️ Better Model Handling

The internal Model type is now exposed, making it easier to work with Huh forms in Bubble Tea applications. This improves type safety and makes composition patterns more natural.

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
    form, cmd := m.form.Update(msg)
    if f, ok := form.(huh.Model); ok {
        m.form = &f
    }
    return m, cmd
}

🧹 Cleaner Dependencies

Huh v2 benefits from the simplified dependency tree of Bubble Tea v2 and Lip Gloss v2. This means faster builds, smaller binaries, and fewer potential version conflicts.

🌈 More on Huh v2

Ready to migrate? Head over to the Upgrade Guide for the full migration checklist.


Changelog

New!

Fixed

Docs

Other stuff


Feedback

Have thoughts on Huh v2? We'd love to hear about it. Let us know on…


Part of Charm.

The Charm logo

Charm热爱开源 • Charm loves open source • نحنُ نحب المصادر المفتوحة

Don't miss a new huh release

NewReleases is sending notifications on new releases.