List (from Box)

A scrollable list which can display selectable items.

Options

  • Inherits all from Box.
  • style.selected - Style for a selected item.
  • style.item - Style for an unselected item.
  • mouse - Whether to automatically enable mouse support for this list (allows clicking items).
  • keys - Use predefined keys for navigating the list.
  • vi - Use vi keys with the keys option.
  • items - An array of strings which become the list's items.
  • search - A function that is called when vi mode is enabled and the key / is pressed. This function accepts a callback function which should be called with the search string. The search string is then used to jump to an item that is found in items.
  • interactive - Whether the list is interactive and can have items selected (Default: true).
  • invertSelected - Whether to automatically override tags and invert fg of item when selected (Default: true).

Properties

  • Inherits all from Box.

Events

  • Inherits all from Box.
  • select - Received when an item is selected.
  • cancel - List was canceled (when esc is pressed with the keys option).
  • action - Either a select or a cancel event was received.

Methods

  • Inherits all from Box.
  • add/addItem(text) - Add an item based on a string.
  • removeItem(child) - Removes an item from the list. Child can be an element, index, or string.
  • pushItem(child) - Push an item onto the list.
  • popItem() - Pop an item off the list.
  • unshiftItem(child) - Unshift an item onto the list.
  • shiftItem() - Shift an item off the list.
  • insertItem(i, child) - Inserts an item to the list. Child can be an element, index, or string.
  • getItem(child) - Returns the item element. Child can be an element, index, or string.
  • setItem(child, content) - Set item to content.
  • spliceItem(i, n, item1, ...) - Remove and insert items to the list.
  • clearItems() - Clears all items from the list.
  • setItems(items) - Sets the list items to multiple strings.
  • getItemIndex(child) - Returns the item index from the list. Child can be an element, index, or string.
  • select(index) - Select an index of an item.
  • move(offset) - Select item based on current offset.
  • up(amount) - Select item above selected.
  • down(amount) - Select item below selected.
  • pick(callback) - Show/focus list and pick an item. The callback is executed with the result.
  • fuzzyFind([string/regex/callback]) - Find an item based on its text content.

Last update: February 22, 2020