Less bugs, more feats
This is a quality-of-life release which fixes a handful of behavioral and rendering issues, and adds a few of useful features.
go get github.com/charmbracelet/huh@latest
Accessible mode: now more accessible
We made several updates to accessible mode, and it should now work better with
screen readers.
It will also now respect WithInput
and WithOutput
.
Focused? Hovered Filtered?
Useful when integrating with an existing Bubble Tea app, you can now get the
currently focused field, as well as the which option the cursor is pointing at, which we’re calling "hover":
f := huh.NewForm(
huh.NewGroup(
huh.NewSelect[string]().
Options(huh.NewOptions(
"Banana",
"Apple",
"Orange",
)...).
Title("Favorite fruit?"),
huh.NewMultiSelect[string]().
Options(huh.NewOptions(
"Pudim",
"Sagu",
"Chocolate",
)...).
Title("Favorite dessert?"),
),
)
_ = f.Run()
field := f.GetFocusedField()
switch field := field.(type) {
case *huh.Select[string]:
fmt.Println(field.Hovered())
case *huh.MultiSelect[string]:
fmt.Println(field.Hovered())
}
You can also use GetFiltering
to check if the user is currently filtering.
Spinning, but not out of control
Spinner
was revamped and now properly handles context cancellations,
interrupts, and more. You can also use the new ActionWithError
to set an action that might error.
Other improvements
FilePicker
got a couple of improvements: you can now set theCursor
, and the UI has received a bit of extra polish.Group
now properly renders theirTitle
andDescription
.Text
can now be configured to not allow opening the external editor.Select
andMultiSelect
now properly handle multi-line options, as well as automatically wrap long options so they are properly rendered.Title
andDescription
of all components now properly wrap, fixing many rendering issues.- Both
Column
andGrid
layouts received bug fixes and improvements. - Interrupt signals (
SIGINT
) are now properly handled.
Changelog
- feat(accessibility): prompt improvements by @caarlos0 in #620
- feat(input): Skip validation when going to previous field by @Sculas in #285
- feat(spinner): improve context, action, output, tests by @caarlos0 in #292
- feat: Add Cursor() methods to Select and MultiSelect fields by @kralicky in #407
- feat: add
WithButtonAlignment
function for button positioning by @bashbunni in #427 - feat: add cursor option to filepicker by @radar07 in #400
- feat: expose focused field by @jonas-grgt in #503
- feat: group titles and descriptions by @caarlos0 in #548
- feat: method to check filtering state of select fields by @jon4hz in #524
- feat: option to disable external editor in Text field by @rahji in #516
- fix rendering of dynamic fields in groups by @zhammer in #505
- fix(accessibility): parseBool defaults to no by @jaredallard in #442
- fix(accessibility): stop scanning on EOF from stdin by @aybabtme in #440
- fix(filepicker): auto-height by @caarlos0 in #464
- fix(filepicker): height, navigation by @caarlos0 in #593
- fix(filepicker): set padding and width to avoid cluttering by @caarlos0 in #465
- fix(select,multiselect): multi line items, scrolling by @caarlos0 in #569
- fix: accessible mode IO, default values, and more by @caarlos0 in #614
- fix: form and group styles by @caarlos0 in #567
- fix: height and width calculation improvements, wrapping by @caarlos0 in #573
- fix: ignore next input bug on Windows by @awoodbeck in #520
- fix: improve timeout by @caarlos0 in #600
- fix: properly handle interrupts by @caarlos0 in #491
- fix: stop using viewport deprecated methods by @caarlos0 in #621
- fix: wrap titles and descriptions when needed by @caarlos0 in #570
- Fixed README GetString to GetInt for bubbletea form example by @hegner123 in #574
- Fixed comment to match function by @hegner123 in #580
- docs(examples): fix typo by @bashbunni in #506
- docs(examples): various small corrections by @meowgorithm in #602
- docs: add example of Dynamic Huh? inside Bubble Tea application by @maaslalani in #347
- Update README.md by @chastain in #575
- chore: basic repo files maintenance by @andreynering in #616
- chore: update github templates by @bashbunni in #603
New Contributors
- @radar07 made their first contribution in #400
- @aybabtme made their first contribution in #440
- @jaredallard made their first contribution in #442
- @awoodbeck made their first contribution in #520
- @jon4hz made their first contribution in #524
- @charmcli made their first contribution in #535
- @jonas-grgt made their first contribution in #503
- @rahji made their first contribution in #516
- @zhammer made their first contribution in #505
- @kralicky made their first contribution in #407
- @hegner123 made their first contribution in #574
- @chastain made their first contribution in #575
- @github-actions made their first contribution in #608
- @andreynering made their first contribution in #616
Thoughts? Questions? We love hearing from you. Feel free to reach out on Twitter, The Fediverse, or Discord.