Documentation ¶
Overview ¶
Package Menu takes a list of choices allowing the user to select a component to push onto the navigation stack. Each choice has a title and a description and a component model implementing tea.Model. tea.Model https://github.com/charmbracelet/bubbletea/blob/a256e76ff5ff142d747ad833c7aa784113f8558c/tea.go#L39
Index ¶
- Variables
- type Choice
- type KeyMap
- type MenuStyles
- type Model
- func (m Model) Init() tea.Cmd
- func (m Model) SelectChoice(choice Choice) (Model, tea.Cmd)
- func (m *Model) SetChoices(choices []Choice, selected *Choice)
- func (m *Model) SetShowTitle(display bool)
- func (m *Model) SetSize(w tea.WindowSizeMsg)
- func (m Model) SetStyles(s MenuStyles)
- func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (m Model) View() string
Constants ¶
This section is empty.
Variables ¶
var DefaultKeyMap = KeyMap{ Select: key.NewBinding( key.WithKeys("enter"), key.WithHelp("enter", "Select current choice"), ), Back: key.NewBinding( key.WithKeys("esc"), key.WithHelp("esc", "Back to previous view"), ), Help: key.NewBinding( key.WithKeys("?", "h"), key.WithHelp("? / h", "toggle help"), ), Quit: key.NewBinding( key.WithKeys("q", "ctrl+c"), key.WithHelp("q / ctrl+c", "quit"), ), }
Functions ¶
This section is empty.
Types ¶
type KeyMap ¶ added in v0.1.2
type MenuStyles ¶ added in v0.1.1
type MenuStyles struct { ListTitleStyle lipgloss.Style ListItemStyles list.DefaultItemStyles }
MenuStyles is a struct that holds the styles for the menu This mostly a passthrough for bubble/list component styles.
type Model ¶
func (Model) SelectChoice ¶ added in v0.1.2
SelectChoice pushes the selected choice onto the navigation stack. If the choice is nil, nothing happens.
func (*Model) SetChoices ¶ added in v0.1.2
func (*Model) SetShowTitle ¶ added in v0.1.3
func (*Model) SetSize ¶
func (m *Model) SetSize(w tea.WindowSizeMsg)
SetSize sets the size of the menu
func (Model) SetStyles ¶ added in v0.1.1
func (m Model) SetStyles(s MenuStyles)
SetStyles allows you to customize the styles used by the menu. This is mostly a passthrough to the bubble/list component used by the menu.