Skip to content

CursorPagination

Newer and Older for lists read with a cursor, where nobody knows the total: logs, events. It says what is on screen instead of «page 3 of ?».

import { CursorPagination } from '@sypnia/ui/react'

On this page
  1. Log lines
  2. When to use it
  3. For everyone
  4. Props

Log lines

Code
import { useState } from 'react';
import { CursorPagination } from '@sypnia/ui/react';

// Logs are read with a cursor: nobody knows the total, so it says what is on screen and offers newer and older.
export default function Logs() {
  const [page, setPage] = useState(0);
  const from = 14 * 60 - page * 25;
  const time = (m: number) => `${String(Math.floor(m / 60)).padStart(2, '0')}:${String(m % 60).padStart(2, '0')}`;
  return <CursorPagination hasPrevious={page > 0} hasNext={page < 5} onPrevious={() => setPage(page - 1)} onNext={() => setPage(page + 1)}
    summary={`50 lines, from ${time(from)} to ${time(from - 24)}`} />;
}

When to use it

Use it when

  • Logs, events and other lists that grow while you read them.

Do not use it when

  • Lists with a known total: use Pagination.

For everyone

  • It is a navigation landmark named «Pages».
  • The summary is read when it changes.

Props

CursorPaginationTypeDefault
hasNextrequired boolean
hasPreviousrequired boolean
onNextrequired () => void
onPreviousrequired () => void
busy boolean
summary

What is on screen: «50 rows, from 14:02 to 13:40».

ReactNode
  1. Log lines
  2. When to use it
  3. For everyone
  4. Props

    Search pages, sections and terms