Skip to content

Pager

A less-like scrollable content viewer for Ink 5. Displays multi-line text content with keyboard scrolling, line numbers, and search.

Install

Terminal window
npm install @matthesketh/ink-pager

Usage

import { Pager } from '@matthesketh/ink-pager';
function App() {
const [offset, setOffset] = useState(0);
return (
<Pager
content={logOutput}
height={20}
showLineNumbers
searchQuery="error"
scrollOffset={offset}
onScroll={setOffset}
/>
);
}

Props

PropTypeDefaultDescription
contentstringrequiredThe text to display
heightnumberrequiredVisible rows
showLineNumbersbooleanfalseShow line numbers on the left
wrapbooleantrueWord wrap long lines
searchQuerystring-Highlight matches in yellow/bold
scrollOffsetnumber0Controlled scroll position
onScroll(offset: number) => void-Scroll position callback

Behaviour

  • Splits content into lines, renders a window of height lines starting from scrollOffset
  • Line numbers shown in dim colour on the left when enabled
  • Word wrap splits long lines to fit terminal width
  • Search query highlights matches in yellow/bold
  • Shows scroll position indicator: Line X-Y of Z at bottom
  • Presentational component only; parent controls scrollOffset