Interface: ScrollListProps
Props for the ScrollList component.
Remarks
Extends ScrollViewProps from ink-scroll-view and adds externally controlled selection with automatic scroll-into-view behavior.
Key Differences from Previous Versions:
- Selection state is now fully controlled by the parent (no internal state)
- Removed
onSelectionChangecallback (parent manages state directly) - Removed imperative selection methods (
select,selectNext, etc.)
Extends
Properties
alignContent?
readonlyoptionalalignContent:"center"|"flex-start"|"flex-end"|"stretch"|"space-between"|"space-around"|"space-evenly"
It defines the alignment along the cross axis when there are multiple lines of flex items (when using flex-wrap). See align-content .
Inherited from
ScrollViewProps.alignContent
alignItems?
readonlyoptionalalignItems:"center"|"flex-start"|"flex-end"|"stretch"|"baseline"
The align-items property defines the default behavior for how items are laid out along the cross axis (perpendicular to the main axis). See align-items .
Inherited from
ScrollViewProps.alignItems
alignSelf?
readonlyoptionalalignSelf:"auto"|"center"|"flex-start"|"flex-end"|"stretch"|"baseline"
It makes possible to override the align-items value for specific flex items. See align-self .
Inherited from
ScrollViewProps.alignSelf
aria-hidden?
readonlyoptionalaria-hidden:boolean
Hide the element from screen readers.
Inherited from
ScrollViewProps.aria-hidden
aria-label?
readonlyoptionalaria-label:string
A label for the element for screen readers.
Inherited from
ScrollViewProps.aria-label
aria-role?
readonlyoptionalaria-role:"button"|"checkbox"|"combobox"|"list"|"listbox"|"listitem"|"menu"|"menuitem"|"option"|"progressbar"|"radio"|"radiogroup"|"tab"|"tablist"|"table"|"textbox"|"timer"|"toolbar"
The role of the element.
Inherited from
ScrollViewProps.aria-role
aria-state?
readonlyoptionalaria-state:object
The state of the element.
busy?
readonlyoptionalbusy:boolean
checked?
readonlyoptionalchecked:boolean
disabled?
readonlyoptionaldisabled:boolean
expanded?
readonlyoptionalexpanded:boolean
multiline?
readonlyoptionalmultiline:boolean
multiselectable?
readonlyoptionalmultiselectable:boolean
readonly?
readonlyoptionalreadonly:boolean
required?
readonlyoptionalrequired:boolean
selected?
readonlyoptionalselected:boolean
Inherited from
ScrollViewProps.aria-state
aspectRatio?
readonlyoptionalaspectRatio:number
Defines the aspect ratio (width/height) for the element.
Use it with at least one size constraint (width, height, minHeight, or maxHeight) so Ink can derive the missing dimension.
Inherited from
ScrollViewProps.aspectRatio
backgroundColor?
readonlyoptionalbackgroundColor:LiteralUnion<keyof ForegroundColor,string>
Background color for the element.
Accepts the same values as color in the <Text> component.
Inherited from
ScrollViewProps.backgroundColor
borderBackgroundColor?
readonlyoptionalborderBackgroundColor:LiteralUnion<keyof ForegroundColor,string>
Change border background color. A shorthand for setting borderTopBackgroundColor, borderRightBackgroundColor, borderBottomBackgroundColor, and borderLeftBackgroundColor.
Inherited from
ScrollViewProps.borderBackgroundColor
borderBottom?
readonlyoptionalborderBottom:boolean
Determines whether the bottom border is visible.
Default
true;Inherited from
ScrollViewProps.borderBottom
borderBottomBackgroundColor?
readonlyoptionalborderBottomBackgroundColor:LiteralUnion<keyof ForegroundColor,string>
Change bottom border background color. Accepts the same values as backgroundColor in Text component.
Inherited from
ScrollViewProps.borderBottomBackgroundColor
borderBottomColor?
readonlyoptionalborderBottomColor:LiteralUnion<keyof ForegroundColor,string>
Change the bottom border color. Accepts the same values as color in Text component.
Inherited from
ScrollViewProps.borderBottomColor
borderBottomDimColor?
readonlyoptionalborderBottomDimColor:boolean
Dim the bottom border color.
Default
false;Inherited from
ScrollViewProps.borderBottomDimColor
borderColor?
readonlyoptionalborderColor:LiteralUnion<keyof ForegroundColor,string>
Change border color. A shorthand for setting borderTopColor, borderRightColor, borderBottomColor, and borderLeftColor.
Inherited from
ScrollViewProps.borderColor
borderDimColor?
readonlyoptionalborderDimColor:boolean
Dim the border color. A shorthand for setting borderTopDimColor, borderBottomDimColor, borderLeftDimColor, and borderRightDimColor.
Default
false;Inherited from
ScrollViewProps.borderDimColor
borderLeft?
readonlyoptionalborderLeft:boolean
Determines whether the left border is visible.
Default
true;Inherited from
ScrollViewProps.borderLeft
borderLeftBackgroundColor?
readonlyoptionalborderLeftBackgroundColor:LiteralUnion<keyof ForegroundColor,string>
Change left border background color. Accepts the same values as backgroundColor in Text component.
Inherited from
ScrollViewProps.borderLeftBackgroundColor
borderLeftColor?
readonlyoptionalborderLeftColor:LiteralUnion<keyof ForegroundColor,string>
Change the left border color. Accepts the same values as color in Text component.
Inherited from
ScrollViewProps.borderLeftColor
borderLeftDimColor?
readonlyoptionalborderLeftDimColor:boolean
Dim the left border color.
Default
false;Inherited from
ScrollViewProps.borderLeftDimColor
borderRight?
readonlyoptionalborderRight:boolean
Determines whether the right border is visible.
Default
true;Inherited from
ScrollViewProps.borderRight
borderRightBackgroundColor?
readonlyoptionalborderRightBackgroundColor:LiteralUnion<keyof ForegroundColor,string>
Change right border background color. Accepts the same values as backgroundColor in Text component.
Inherited from
ScrollViewProps.borderRightBackgroundColor
borderRightColor?
readonlyoptionalborderRightColor:LiteralUnion<keyof ForegroundColor,string>
Change the right border color. Accepts the same values as color in Text component.
Inherited from
ScrollViewProps.borderRightColor
borderRightDimColor?
readonlyoptionalborderRightDimColor:boolean
Dim the right border color.
Default
false;Inherited from
ScrollViewProps.borderRightDimColor
borderStyle?
readonlyoptionalborderStyle: keyof Boxes |BoxStyle
Add a border with a specified style. If borderStyle is undefined (the default), no border will be added.
Inherited from
ScrollViewProps.borderStyle
borderTop?
readonlyoptionalborderTop:boolean
Determines whether the top border is visible.
Default
true;Inherited from
ScrollViewProps.borderTop
borderTopBackgroundColor?
readonlyoptionalborderTopBackgroundColor:LiteralUnion<keyof ForegroundColor,string>
Change top border background color. Accepts the same values as backgroundColor in Text component.
Inherited from
ScrollViewProps.borderTopBackgroundColor
borderTopColor?
readonlyoptionalborderTopColor:LiteralUnion<keyof ForegroundColor,string>
Change the top border color. Accepts the same values as color in Text component.
Inherited from
ScrollViewProps.borderTopColor
borderTopDimColor?
readonlyoptionalborderTopDimColor:boolean
Dim the top border color.
Default
false;Inherited from
ScrollViewProps.borderTopDimColor
bottom?
readonlyoptionalbottom:string|number
Bottom offset for positioned elements.
Inherited from
ScrollViewProps.bottom
children?
optionalchildren:ReactNode
The content to be scrolled.
Remarks
Accepts an array of React elements. Each element should have a unique key
prop, which will be preserved during rendering for proper reconciliation.
Inherited from
ScrollViewProps.children
columnGap?
readonlyoptionalcolumnGap:number
Size of the gap between an element’s columns.
Inherited from
ScrollViewProps.columnGap
debug?
optionaldebug:boolean
Enable debug mode to visualize the ScrollView internals.
Remarks
When enabled, the viewport overflow is not hidden, allowing the full content to be visible. This is useful for inspecting the layout and verifying that content is being rendered correctly off-screen.
Inherited from
ScrollViewProps.debug
display?
readonlyoptionaldisplay:"flex"|"none"
Set this property to none to hide the element.
Inherited from
ScrollViewProps.display
flexBasis?
readonlyoptionalflexBasis:string|number
It specifies the initial size of the flex item, before any available space is distributed according to the flex factors. See flex-basis .
Inherited from
ScrollViewProps.flexBasis
flexDirection?
readonlyoptionalflexDirection:"row"|"column"|"row-reverse"|"column-reverse"
It establishes the main-axis, thus defining the direction flex items are placed in the flex container. See flex-direction .
Inherited from
ScrollViewProps.flexDirection
flexGrow?
readonlyoptionalflexGrow:number
This property defines the ability for a flex item to grow if necessary. See flex-grow .
Inherited from
ScrollViewProps.flexGrow
flexShrink?
readonlyoptionalflexShrink:number
It specifies the “flex shrink factor”, which determines how much the flex item will shrink relative to the rest of the flex items in the flex container when there isn’t enough space on the row. See flex-shrink .
Inherited from
ScrollViewProps.flexShrink
flexWrap?
readonlyoptionalflexWrap:"nowrap"|"wrap"|"wrap-reverse"
It defines whether the flex items are forced in a single line or can be flowed into multiple lines. If set to multiple lines, it also defines the cross-axis which determines the direction new lines are stacked in. See flex-wrap .
Inherited from
ScrollViewProps.flexWrap
gap?
readonlyoptionalgap:number
Size of the gap between an element’s columns and rows. A shorthand for columnGap and rowGap.
Inherited from
ScrollViewProps.gap
height?
readonlyoptionalheight:string|number
Height of the element in lines (rows). You can also set it as a percentage, which will calculate the height based on the height of the parent element.
Inherited from
ScrollViewProps.height
justifyContent?
readonlyoptionaljustifyContent:"center"|"flex-start"|"flex-end"|"space-between"|"space-around"|"space-evenly"
It defines the alignment along the main axis. See justify-content .
Inherited from
ScrollViewProps.justifyContent
left?
readonlyoptionalleft:string|number
Left offset for positioned elements.
Inherited from
ScrollViewProps.left
margin?
readonlyoptionalmargin:number
Margin on all sides. Equivalent to setting marginTop, marginBottom, marginLeft, and marginRight.
Inherited from
ScrollViewProps.margin
marginBottom?
readonlyoptionalmarginBottom:number
Bottom margin.
Inherited from
ScrollViewProps.marginBottom
marginLeft?
readonlyoptionalmarginLeft:number
Left margin.
Inherited from
ScrollViewProps.marginLeft
marginRight?
readonlyoptionalmarginRight:number
Right margin.
Inherited from
ScrollViewProps.marginRight
marginTop?
readonlyoptionalmarginTop:number
Top margin.
Inherited from
ScrollViewProps.marginTop
marginX?
readonlyoptionalmarginX:number
Horizontal margin. Equivalent to setting marginLeft and marginRight.
Inherited from
ScrollViewProps.marginX
marginY?
readonlyoptionalmarginY:number
Vertical margin. Equivalent to setting marginTop and marginBottom.
Inherited from
ScrollViewProps.marginY
maxHeight?
readonlyoptionalmaxHeight:string|number
Sets a maximum height of the element in lines (rows). You can also set it as a percentage, which will calculate the maximum height based on the height of the parent element.
Inherited from
ScrollViewProps.maxHeight
maxWidth?
readonlyoptionalmaxWidth:string|number
Sets a maximum width of the element. Percentages aren’t supported yet; see https://github.com/facebook/yoga/issues/872 .
Inherited from
ScrollViewProps.maxWidth
minHeight?
readonlyoptionalminHeight:string|number
Sets a minimum height of the element in lines (rows). You can also set it as a percentage, which will calculate the minimum height based on the height of the parent element.
Inherited from
ScrollViewProps.minHeight
minWidth?
readonlyoptionalminWidth:string|number
Sets a minimum width of the element. Percentages aren’t supported yet; see https://github.com/facebook/yoga/issues/872 .
Inherited from
ScrollViewProps.minWidth
onContentHeightChange()?
optionalonContentHeightChange: (height,previousHeight) =>void
Callback fired when the total height of the content changes.
Parameters
height
number
The new total content height.
previousHeight
number
The previous total content height.
Returns
void
Remarks
Useful for debug logging or adjusting external layouts based on content size.
Inherited from
ScrollViewProps.onContentHeightChange
onItemHeightChange()?
optionalonItemHeightChange: (index,height,previousHeight) =>void
Callback fired when an individual child item’s height changes.
Parameters
index
number
The index of the item.
height
number
The new height of the item.
previousHeight
number
The previous height of the item.
Returns
void
Remarks
This is triggered whenever an item is re-measured and its height differs from the previous value.
Inherited from
ScrollViewProps.onItemHeightChange
onScroll()?
optionalonScroll: (scrollOffset) =>void
Callback fired when the scroll position changes.
Parameters
scrollOffset
number
The new scroll offset (distance from top).
Returns
void
Remarks
Use this to sync external state or UI (e.g., scrollbars) with the current scroll position.
Inherited from
ScrollViewProps.onScroll
onViewportSizeChange()?
optionalonViewportSizeChange: (size,previousSize) =>void
Callback fired when the ScrollView viewport (visible area) dimensions change.
Parameters
size
The new dimensions of the viewport (width, height).
height
number
width
number
previousSize
The previous dimensions of the viewport (width, height).
height
number
width
number
Returns
void
Remarks
Fired whenever the outer container size changes (e.g., terminal resize or layout update).
Inherited from
ScrollViewProps.onViewportSizeChange
overflow?
readonlyoptionaloverflow:"visible"|"hidden"
Behavior for an element’s overflow in both directions.
Default
"visible";Inherited from
ScrollViewProps.overflow
overflowX?
readonlyoptionaloverflowX:"visible"|"hidden"
Behavior for an element’s overflow in the horizontal direction.
Default
"visible";Inherited from
ScrollViewProps.overflowX
overflowY?
readonlyoptionaloverflowY:"visible"|"hidden"
Behavior for an element’s overflow in the vertical direction.
Default
"visible";Inherited from
ScrollViewProps.overflowY
padding?
readonlyoptionalpadding:number
Padding on all sides. Equivalent to setting paddingTop, paddingBottom, paddingLeft, and paddingRight.
Inherited from
ScrollViewProps.padding
paddingBottom?
readonlyoptionalpaddingBottom:number
Bottom padding.
Inherited from
ScrollViewProps.paddingBottom
paddingLeft?
readonlyoptionalpaddingLeft:number
Left padding.
Inherited from
ScrollViewProps.paddingLeft
paddingRight?
readonlyoptionalpaddingRight:number
Right padding.
Inherited from
ScrollViewProps.paddingRight
paddingTop?
readonlyoptionalpaddingTop:number
Top padding.
Inherited from
ScrollViewProps.paddingTop
paddingX?
readonlyoptionalpaddingX:number
Horizontal padding. Equivalent to setting paddingLeft and paddingRight.
Inherited from
ScrollViewProps.paddingX
paddingY?
readonlyoptionalpaddingY:number
Vertical padding. Equivalent to setting paddingTop and paddingBottom.
Inherited from
ScrollViewProps.paddingY
position?
readonlyoptionalposition:"absolute"|"relative"|"static"
Controls how the element is positioned.
When position is static, top, right, bottom, and left are ignored.
Inherited from
ScrollViewProps.position
right?
readonlyoptionalright:string|number
Right offset for positioned elements.
Inherited from
ScrollViewProps.right
rowGap?
readonlyoptionalrowGap:number
Size of the gap between an element’s rows.
Inherited from
ScrollViewProps.rowGap
scrollAlignment?
optionalscrollAlignment:ScrollAlignment
Alignment mode when scrolling to the selected item.
Remarks
Controls how the selected item is positioned within the viewport when auto-scrolling.
Modes:
'auto': Minimal scrolling to bring item into view (default). Best for keyboard navigation.'top': Align item to the top of the viewport. Good for “jump to” navigation.'bottom': Align item to the bottom of the viewport.'center': Align item to the center of the viewport. Best for search result highlighting.
Examples:
// Default auto behavior - minimal scrolling
<ScrollList selectedIndex={index} scrollAlignment="auto" />
// Always center the selected item - good for search/spotlight UX
<ScrollList selectedIndex={searchResultIndex} scrollAlignment="center" />Default Value
'auto'
selectedIndex?
optionalselectedIndex:number
The currently selected item index (controlled by parent).
Remarks
When this value changes, the component will automatically scroll to ensure
the selected item is visible in the viewport according to the scrollAlignment mode.
Important Behaviors:
- The selection state is entirely controlled by the parent component.
- Invalid indices (negative or >= item count) are handled gracefully - no scrolling occurs.
- When
undefined, the component does not perform auto-scrolling (useful for manual scroll control). - The component does NOT clamp or modify this value - the parent is responsible for bounds checking.
Example
const [selectedIndex, setSelectedIndex] = useState(0);
useInput((input, key) => {
if (key.downArrow) {
setSelectedIndex((prev) => Math.min(prev + 1, items.length - 1));
}
});
<ScrollList selectedIndex={selectedIndex}>
{items.map((item, i) => (
<ListItem key={i} selected={i === selectedIndex} />
))}
</ScrollList>;top?
readonlyoptionaltop:string|number
Top offset for positioned elements.
Inherited from
ScrollViewProps.top
width?
readonlyoptionalwidth:string|number
Width of the element in spaces. You can also set it as a percentage, which will calculate the width based on the width of the parent element.
Inherited from
ScrollViewProps.width