Skip to main content

ScrollBar

Let users move forward or backward through a collection. Your app updates the visible content.

ScrollBar in a native Kindle example

Usage​

Save this example as apps/Reader/App.js in the starter app.

import React, {useState} from 'react';
import {ScrollBar, Text, View} from 'react-kindle';

export default function App() {
const [index, setIndex] = useState(0);

return (
<View style={{padding: 24, flexDirection: 'row', height: 420}}>
<View style={{flex: 1}}>
{Array.from({length: 5}, (_, row) => (
<Text key={row} style={{height: 64}}>Book {index + row + 1}</Text>
))}
</View>
<ScrollBar index={index} count={20} pageSize={5} style={{width: 40, height: 360}}
onForward={() => setIndex(value => Math.min(15, value + 5))}
onBackward={() => setIndex(value => Math.max(0, value - 5))} />
</View>
);
}

Props​

PropType / defaultDescription
indexnonnegative integerFirst visible item index.
countnonnegative integerTotal number of items.
pageSizepositive integerNumber of visible items.
horizontalboolean = falseScrollbar direction.
onForward / onBackward() => voidMovement callbacks.
styleView styleSet scrollbar dimensions.

The screenshot shows ScrollBar at the far right of a scrolling list. It only reports direction; connect its callbacks to your own paging state or a controlled ScrollView.