Skip to content

List

widgetsinput

List: a scrollable, selectable list of items

Installation

$ bunx termuijs add list

Copies the source into src/components/list/ and installs @termuijs/core, @termuijs/widgets.

Usage

ts
import { List } from '@termuijs/widgets'
ts
new List(itemsOrProps: ListItem[] | ListProps, style: Partial<Style> = {}, onSelect?: (item: ListItem, index: number) => void,)

API Reference

List

PropTypeRequiredDescription
itemsListItem[]optional
stylePartial<Style>optional
onSelect(item: ListItem, index: number) => voidoptional
stateListStateoptionalExternal state object – if provided, List reads/writes selection through it
onStateChange(state: ListState) => voidoptionalCalled whenever selection or scroll changes
emptyMessagestringoptionalMessage to display when the list is empty
reorderablebooleanoptionalAllow items to be reordered via moveItem()
#input#list