Comma Agents
@comma-agents/tuiComponents

ScrollableList

Generic single-selection list with arrow-key navigation and row-aware scrollbar.

ScrollableList

A generic single-selection list with Up/Down arrow navigation, Enter to select, and a row-aware vertical scrollbar. Built as a selection layer over ScrollableView.

import { ScrollableList } from "@comma-agents/tui";

<ScrollableList
  items={files}
  getKey={(file) => file.id}
  renderItem={(file, isSelected) => (
    <Text color={isSelected ? "blue" : undefined}>{file.name}</Text>
  )}
  selectedIndex={selectedIndex}
  onSelectedIndexChange={setSelectedIndex}
  onSelected={(file, index) => openFile(file)}
/>

ScrollableListProps

PropTypeDescription
itemsreadonly ItemType[]Items to display
getKey(item, index) => stringUnique key for each item
renderItem(item, isSelected) => ReactNodeRender function; isSelected is true for the active item
selectedIndexnumberControlled; clamped to [0, items.length - 1]
onSelectedIndexChange(next: number) => voidCalled when the user moves selection
onSelected(item, index) => voidCalled on Enter
emptyTextstringText shown when list is empty (default: "No items.")
idstringStable focus ID for tab order
isFocusedbooleanExternal focus override

Keyboard

KeyAction
UpMove selection up
DownMove selection down
EnterInvoke onSelected with the selected item

The selected row is always kept visible via scrollToRow. When isFocused is provided, the list defers focus control entirely to the parent component.

On this page