Skip to content

Releases: charmbracelet/huh

v0.6.0

06 Sep 16:35
a9285a0
Compare
Choose a tag to compare

Just focus

This release features automatic window focus events support for the Input and Text components.

Note that if you're using Huh in a larger Bubble Tea program you’ll need WithReportFocus to enable focus events.

p := tea.NewProgram(model{}, tea.WithReportFocus())

Happy focusing!

Changelog

New!

Full Changelog: v0.5.3...v0.6.0

v0.5.3

23 Aug 13:41
5fd7081
Compare
Choose a tag to compare

Crushin’ bugs

This release fixes a buncha bugs in Huh and Gum alike. Gum users, stay tuned for an update later today.

What's Changed

Fixed

Other Stuff

New Contributors

Full Changelog: v0.5.2...v0.5.3

v0.5.2

24 Jul 18:14
41be8ec
Compare
Choose a tag to compare

Lil’ fixes ’n’ improvements

Hi! This is a maintenance release to fix issues with dynamic forms as well as address issues with Gum upstream.

Changelog

New

Fixed

  • improve distinction in field select by @csandeep in #304
  • fix invalid order of event handling in input/text fields by @Sculas in #284

New Contributors

Full Changelog: v0.5.1...v0.5.2


The Charm logo

Thoughts? Questions? We love hearing from you. Feel free to reach out on Twitter, The Fediverse, or Discord.

v0.5.0

09 Jul 22:11
v0.5.0
4289f94
Compare
Choose a tag to compare

This big news in this release is that forms in Huh can now be dynamic. Read on for more:

Dynamic Forms 🪄

Country / State form with dynamic inputs running.

huh? forms can now react to changes in other parts of the form. Replace properties such as Options, Title, Description with their dynamic counterparts: OptionsFunc, TitleFunc, and DescriptionFunc to recompute properties values on changes when watched variables change.

Let’s build a simple state / province picker.

var country string
var state string

The country select will be static, we’ll use this value to recompute the
options and title for the next input.

huh.NewSelect[string]().
    Options(huh.NewOptions("United States", "Canada", "Mexico")...).
    Value(&country).
    Title("Country").

Define your Select with TitleFunc and OptionsFunc and bind them to the
&country value from the previous field. Whenever the user chooses a different
country, the TitleFunc and OptionsFunc will be recomputed.

Important

We have to pass &country as the binding to recompute the function only when
country changes, otherwise we will hit the API too often.

huh.NewSelect[string]().
    Value(&state).
    Height(8).
    TitleFunc(func() string {
        switch country {
        case "United States":
            return "State"
        case "Canada":
            return "Province"
        default:
            return "Territory"
        }
    }, &country).
    OptionsFunc(func() []huh.Option[string] {
        opts := fetchStatesForCountry(country)
        return huh.NewOptions(opts...)
    }, &country),

Lastly, run the form with these inputs.

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

Changelog

New!

Fixed

New Contributors

Full Changelog: v0.4.2...v0.5.0


The Charm logo

Thoughts? Questions? We love hearing from you. Feel free to reach out on Twitter, The Fediverse, or Discord.

v0.4.2

25 May 17:42
v0.4.2
200f55b
Compare
Choose a tag to compare

Your favourite files 📁

Huh? v0.4.0 (v0.4.2) introduces the File Picker to forms ✨

Prompt users to select a file in just a few lines of code, you know the drill :)

var file string

huh.NewFilePicker().
    Title("Select a file:").
    Description("This will be your profile image.").
    AllowedTypes([]string{".png", ".jpeg", ".webp", ".gif"}).
    Value(&file)

Made with VHS


Field Interface

Zoom

File pickers introduce a new Zoom method to the Field interface.

type Field interface {

    // ...

    Zoom() bool

    // ...

}

Zoom tells the form whether this field should be the only visible field.

Notice how the FilePicker field zooms in when selecting a file and zooms out when the file is selected, showing only the selected file.

Skip

Notes introduce a new Skip method to the Field interface.

type Field interface {

    // ...

    Skip() bool

    // ...

}

Skip indicates to the form whether or not to skip this field, i.e. don't let the user interact with it. This is useful for notes to be purely informational.

What else?

Bug Fixes

New Contributors

A special thanks to everyone who made this release of Huh? possible! 🤗

Full Changelog: v0.3.0...v0.4.0


The Charm logo

Thoughts? Questions? We love hearing from you. Feel free to reach out on Twitter, The Fediverse, or Slack.

v0.3.0

25 Jan 17:47
v0.3.0
355812c
Compare
Choose a tag to compare

Scrolling, autocomplete, smaller binaries and more!

This is a big release with a tonne of new features.

  • Scrollable Forms
  • Scrollable Selects and Multi selects
  • Autocomplete for inputs
  • 7x smaller binaries
  • Multi select filtering
  • Lotsa' bugfixes and quality-of-life improvements

To upgrade to huh v0.3.0:

go get -u github.com/charmbracelet/huh@latest

For details read on!

Scrollable forms

If a form is in a small terminal it will automatically resize to fit the available space and the active group will scroll to stay in view. Form heights can also be set manually with the new WithHeight method.

Made with VHS

Select and Multi select Scrolling

Select and Multi select fields can now be restricted to a certain height, allowing their options to be scrollable. This means you can now pack in tonnes of options.

To make a Select or MultiSelect scrollable simply set the height on the field or form through the Height method.

s := huh.NewSelect()
    .Title("What’s for dinner?")
    .Options(/* ... */)
    .Height(height)

Made with VHS

Autocomplete

Now Inputs can offer suggestions making it easier for users to fill out inputs. These suggestions can be accepted autocomplete-style with a configurable key binding (which defaults to ctrl+e).

Simply provide a []string to Suggestions to enable this feature.

huh.NewInput().
    Title("What's for lunch?").
    Prompt("? ").
    Suggestions([]string{
        "Artichoke",
        // ...
        "Cashew Apple",
        "Cashews",
        "Cat Food",
        "Coconut Milk",
        "Cucumber",
        "Curry Paste",
        "Currywurst",
        // ...
    })

Made with VHS

More helpful help

Forms will automatically adjust their help text to indicate to the user whether the form will continue or submit on actions. This works with hidden groups. In the below example, the user will be asked to list their allergies if they select "Yes" otherwise, the form will submit.

Made with VHS

Way smaller binaries

Huh now produces way smaller binaries! Thanks to #94 Huh now has a 7x smaller compiled footprint.

Before, using [email protected]:

33M     ./burger

After, using [email protected]:

4.5M    ./burger

Thanks, Vitor!

Special thanks to the intrepid @vitor-mariano, one of the earliest huh contributors, who came in hot with features, fixes, improvements and good vibes. Thank you, Vitor!

Changelog

New

Fixed

Full Changelog: v0.2.3...v0.3.0


The Charm logo

Thoughts? Questions? We love hearing from you. Feel free to reach out on Twitter, The Fediverse, or on Discord.

v0.2.3

18 Dec 16:08
v0.2.3
47340b5
Compare
Choose a tag to compare

Better Defaults!

Huh? v0.2.3 fixes some bugs for more consistent behaviour across inputs 🐞

  • Text inputs now update values on each keystroke rather than on Blur for consistency.
  • Select and MultiSelect read their default values from the initial values set by the Value variable if provided.

A special thanks to @vitor-mariano for all his contributions to this release 🤗

Defaults Example

You can now have preselected options by declaring them in the Value variable:

var toppings = []string{"Lettuce", "Tomatoes"}
var options = huh.NewOptions("Lettuce", "Tomatoes", "Charm Sauce", "Cheese", "Vegan Cheese")

huh.NewMultiSelect[string]().Title("Toppings").Options(options...).Value(&toppings).Run()

In the above example, Lettuce and Tomatoes will be preselected by default.

What's Changed

Full Changelog: v0.2.2...v0.2.3


The Charm logo

Thoughts? Questions? We love hearing from you. Feel free to reach out on Twitter, The Fediverse, or on Discord.

v0.2.2

15 Dec 19:26
v0.2.2
3c09142
Compare
Choose a tag to compare

Better Wrapping 🎁

Huh? v0.2.2 improves wrapping of the Input and Text fields.
It applies width set on the form to the inputs to perform wrapping based on the specified or terminal width.

New Contributors

Full Changelog: v0.2.1...v0.2.2


The Charm logo

Thoughts? Questions? We love hearing from you. Feel free to reach out on Twitter, The Fediverse, or Discord.

v0.2.1

13 Dec 04:27
v0.2.1
4086645
Compare
Choose a tag to compare

New Theme! 😸

huh? forms can now use Catppuccin themes. (Thanks to the wonderful @sgoudham ✨)

Simply add the following to your huh.Forms:

.WithTheme(huh.ThemeCatppuccin())

The Charm logo

Thoughts? Questions? We love hearing from you. Feel free to reach out on Twitter, The Fediverse, or Discord.

v0.2.0

12 Dec 20:06
v0.2.0
77c4239
Compare
Choose a tag to compare

Better Help Styles!

Help Styles now apply on a Theme rather than embedded in FieldStyles. (Thanks to the wonderful @jolheiser ✨)

// Old...
theme.Focused.Help.ShortKey = lipgloss.NewStyle() //...

// Updated!
theme.Help.ShortKey = lipgloss.NewStyle() //...

The Charm logo

Thoughts? Questions? We love hearing from you. Feel free to reach out on Twitter, The Fediverse, or Discord.