-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(multiselect): set viewport height in WithHeight(#350)
* chore: add example of multiple groups with varying heights * fix(multiselect): set viewport height in initial render
- Loading branch information
Showing
2 changed files
with
82 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/charmbracelet/huh" | ||
) | ||
|
||
func main() { | ||
f := huh.NewForm( | ||
huh.NewGroup( | ||
huh.NewSelect[string](). | ||
Options( | ||
huh.NewOption("A", "a"), | ||
huh.NewOption("B", "b"), | ||
huh.NewOption("C", "c"), | ||
huh.NewOption("D", "d"), | ||
huh.NewOption("E", "e"), | ||
huh.NewOption("F", "f"), | ||
huh.NewOption("G", "g"), | ||
huh.NewOption("H", "h"), | ||
huh.NewOption("I", "i"), | ||
huh.NewOption("J", "j"), | ||
huh.NewOption("K", "k").Selected(true), | ||
huh.NewOption("L", "l"), | ||
huh.NewOption("M", "m"), | ||
huh.NewOption("N", "n"), | ||
huh.NewOption("O", "o"), | ||
huh.NewOption("P", "p"), | ||
), | ||
).WithHeight(8), | ||
huh.NewGroup( | ||
huh.NewMultiSelect[string](). | ||
Options( | ||
huh.NewOption("A", "a"), | ||
huh.NewOption("B", "b"), | ||
huh.NewOption("C", "c"), | ||
huh.NewOption("D", "d"), | ||
huh.NewOption("E", "e"), | ||
huh.NewOption("F", "f"), | ||
huh.NewOption("G", "g"), | ||
huh.NewOption("H", "h"), | ||
huh.NewOption("I", "i"), | ||
huh.NewOption("K", "k").Selected(true), | ||
huh.NewOption("L", "l"), | ||
huh.NewOption("M", "m"), | ||
huh.NewOption("N", "n"), | ||
huh.NewOption("O", "o").Selected(true), | ||
huh.NewOption("P", "p"), | ||
), | ||
).WithHeight(10), | ||
huh.NewGroup( | ||
huh.NewSelect[string](). | ||
Options( | ||
huh.NewOption("A", "a"), | ||
huh.NewOption("B", "b"), | ||
huh.NewOption("C", "c"), | ||
huh.NewOption("D", "d"), | ||
huh.NewOption("E", "e"), | ||
huh.NewOption("F", "f"), | ||
huh.NewOption("G", "g"), | ||
huh.NewOption("H", "h"), | ||
huh.NewOption("I", "i"), | ||
huh.NewOption("J", "j"), | ||
huh.NewOption("K", "k").Selected(true), | ||
huh.NewOption("L", "l"), | ||
huh.NewOption("M", "m"), | ||
huh.NewOption("N", "n"), | ||
huh.NewOption("O", "o"), | ||
huh.NewOption("P", "p"), | ||
), | ||
).WithHeight(5), | ||
) | ||
|
||
if err := f.Run(); err != nil { | ||
fmt.Fprintf(os.Stderr, "Oof: %v", err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters