The palette package provides a Bubble Tea component designed for building command palettes. It supports pluggable modes that allow you to:
- Perform fuzzy filtering on a static list of items.
- Dispatch asynchronous searches.
- Mix both filtering and async searching using different prefixes.
Each palette.Mode manages its own Match logic, Items retrieval, and can optionally include an async Search function or typeable Facets.
import "github.com/stripe/stripe-cli/pkg/docs/internal/palette"
var commands = []palette.Item{
palette.Command{Name: "Open file"},
palette.Command{Name: "Save"},
palette.Command{Name: "Quit"},
}
mode := palette.Mode{
Name: "commands",
Items: func(_ palette.Model, q string) []palette.Item {
return palette.FilterFuzzy(commands, q)
},
}
p := palette.New(palette.WithModes(mode))