ASCII-styled pagination component with page numbers, navigation arrows, and smart ellipsis handling.
npm install react-ascii-ui
import { AsciiPagination } from 'react-ascii-ui';
export default function Example() {
const [currentPage, setCurrentPage] = useState(1);
const totalPages = 20;
return (
<AsciiPagination
currentPage={currentPage}
totalPages={totalPages}
onPageChange={setCurrentPage}
/>
);
}<AsciiPagination
currentPage={3}
totalPages={10}
onPageChange={handlePageChange}
/><AsciiPagination
currentPage={15}
totalPages={100}
onPageChange={handlePageChange}
/><AsciiPagination
currentPage={8}
totalPages={25}
onPageChange={handlePageChange}
maxVisiblePages={3}
/><AsciiPagination
currentPage={5}
totalPages={20}
onPageChange={handlePageChange}
showFirstLast={false}
/><AsciiPagination
currentPage={2}
totalPages={4}
onPageChange={handlePageChange}
/>// First page - Previous button disabled
<AsciiPagination currentPage={1} totalPages={10} onPageChange={...} />
// Last page - Next button disabled
<AsciiPagination currentPage={10} totalPages={10} onPageChange={...} />| Prop | Type | Default | Description |
|---|---|---|---|
| currentPage | number | - | Current active page number |
| totalPages | number | - | Total number of pages |
| onPageChange | (page: number) => void | - | Callback when page is changed |
| maxVisiblePages | number | 5 | Maximum number of page buttons to show |
| showFirstLast | boolean | true | Whether to show first and last page buttons |
| className | string | "" | Additional CSS classes |
AsciiPagination extends all HTML div attributes and supports all React div props.