Skip to content

SelectList

A keyboard-navigable single-select list. Supports controlled and uncontrolled modes. Items can be disabled.

Import

tsx
import { SelectList } from "silvery"

Props

PropTypeDefaultDescription
itemsSelectOption[]requiredList of options
highlightedIndexnumber--Controlled: current highlighted index
onHighlight(index: number) => void--Called when highlight changes
onSelect(option: SelectOption, index: number) => void--Called when user confirms selection (Enter)
initialIndexnumberfirst enabledInitial index for uncontrolled mode
maxVisiblenumber--Max visible items (rest scrolled)
isActivebooleantrueWhether this list captures input
indicatorstring"▸ "Selection indicator prefix ("" to hide)

SelectOption

ts
interface SelectOption {
  label: string
  value: string
  disabled?: boolean
}

Keyboard Shortcuts

KeyAction
j / DownMove highlight down
k / UpMove highlight up
EnterConfirm selection
Ctrl+AJump to first enabled item
Ctrl+EJump to last enabled item

Usage

tsx
const items = [
  { label: "Apple", value: "apple" },
  { label: "Banana", value: "banana" },
  { label: "Cherry", value: "cherry", disabled: true },
]

<SelectList items={items} onSelect={(opt) => console.log(opt.value)} />

// Controlled mode
<SelectList
  items={items}
  highlightedIndex={selected}
  onHighlight={setSelected}
  onSelect={handleSelect}
/>

See Also

Released under the MIT License.