Skip to content

KeyHintBar

KeyHintBar preview

KeyHintBar displays key hints in a pill style at the bottom of views/modals.

Constructor func NewKeyHintBar() *KeyHintBar

Usage

bar := components.NewKeyHintBar().
SetHints([]components.KeyHint{
{Key: "Enter", Description: "Select"},
{Key: "j/k", Description: "Navigate"},
{Key: "Esc", Description: "Back"},
})
fmt.Println(bar != nil)

Methods

Method Signature Description
AddHint func (k *KeyHintBar) AddHint(key, description string) *KeyHintBar AddHint adds a single hint.
Clear func (k *KeyHintBar) Clear() *KeyHintBar Clear removes all hints.
GetPreferredHeight func (k *KeyHintBar) GetPreferredHeight() int GetPreferredHeight returns the preferred height for the hint bar.
SetHints func (k *KeyHintBar) SetHints(hints []KeyHint) *KeyHintBar SetHints sets the hints to display.

Types

type KeyHint struct KeyHint represents a single key binding hint.
FieldTypeDescription
Key string e.g., "Enter", "Esc", "Space", "j/k"
Description string e.g., "Select", "Close", "Toggle"