Skip to content

ScrollbackList

Declarative wrapper around useScrollback. Manages a list of items where completed items freeze into terminal scrollback. Items signal completion by calling freeze() from the useScrollbackItem hook.

The component enforces a contiguous prefix invariant: items freeze in order from the start.

Import

tsx
import { ScrollbackList } from "silvery"

Props

PropTypeDefaultDescription
itemsT[]requiredArray of items to render
children(item: T, index: number) => ReactNode--Render function for each item
renderItem(item: T, index: number) => ReactNode--Alternative render function
keyExtractor(item: T, index: number) => string | numberrequiredExtract a unique key for each item
isFrozen(item: T, index: number) => boolean--Data-driven frozen predicate
footerReactNode--Footer pinned at the bottom
markersboolean | ScrollbackMarkerCallbacks<T>--OSC 133 marker configuration
widthnumberprocess.stdout.columnsTerminal width in columns
stdout{ write(data: string): boolean }process.stdoutOutput stream
onRecovery() => void--Called on inconsistent state recovery

Usage

tsx
function App() {
  const [tasks, setTasks] = useState<Task[]>(initialTasks)

  return (
    <ScrollbackList items={tasks} keyExtractor={(t) => t.id} footer={<Text>Status bar</Text>}>
      {(task) => <TaskItem task={task} />}
    </ScrollbackList>
  )
}

function TaskItem({ task }: { task: Task }) {
  const { freeze } = useScrollbackItem()
  useEffect(() => {
    if (task.done) freeze()
  }, [task.done])
  return <Text>{task.title}</Text>
}

See Also

Released under the MIT License.