Skip to content

HintGrid

HintGrid preview

HintGrid renders a collection of KeyHint items in a multi-row pill layout. Unlike KeyHintBar which only renders a single row, HintGrid wraps hints onto multiple rows when they don't fit the available width, and centers each row horizontally.

Constructor func NewHintGrid() *HintGrid

Usage

grid := components.NewHintGrid().
SetHints([]components.KeyHint{
{Key: "j/k", Description: "Navigate"},
{Key: "Enter", Description: "Select"},
{Key: "Space", Description: "Toggle"},
{Key: "Ctrl+S", Description: "Save"},
{Key: "Esc", Description: "Close"},
})
fmt.Println(grid != nil)

Methods

Method Signature Description
GetPreferredHeight func (g *HintGrid) GetPreferredHeight(width int) int GetPreferredHeight returns the total height needed to display all hints at the given width, including a blank-line gap between rows.
SetHints func (g *HintGrid) SetHints(hints []KeyHint) *HintGrid 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"