The Pagination component provides page navigation with optional items-per-page selection and item count information.
npm install @dt-dds/react-paginationThe Pagination component provides page navigation with optional items-per-page selection and item count information.
``jsx
import { Pagination } from '@dt-dds/react';
const Example = () => {
const [currentPage, setCurrentPage] = useState(1);
const [itemsPerPage, setItemsPerPage] = useState(10);
return (
totalPages={20}
totalItems={200}
itemsPerPage={itemsPerPage}
onPageChange={setCurrentPage}
onItemsPerPageChange={setItemsPerPage}
showItemsPerPage
showItemsInfo
/>
);
};
`
| Property | Type | Default | Description |
| ---------------------- | ------------------------- | ------------------- | ------------------------------------------------------ |
| currentPage | number | — | Currently selected page (1-based index) |totalPages
| | number | — | Total number of available pages |totalItems
| | number | — | Total number of items across all pages |itemsPerPage
| | number | 10 | Number of items displayed per page |onPageChange
| | (page: number) => void | — | Callback fired when the current page changes |onItemsPerPageChange
| | (items: number) => void | — | Callback fired when items-per-page value changes |showItemsPerPage
| | boolean | false | Controls visibility of the items-per-page selector |showItemsInfo
| | boolean | true | Controls visibility of the items information text |itemsPerPageOptions
| | number[] | [10, 20, 50, 100] | Available options for items per page |dataTestId
| | string | pagination | Custom test identifier for the pagination root element |
- TypeScript for static type checking
- React — JavaScript library for user interfaces
- Emotion — for writing css styles with JavaScript
- Storybook — UI component environment powered by Vite
- Jest - JavaScript Testing Framework
- React Testing Library - to test UI components in a user-centric way
- ESLint for code linting
- Prettier for code formatting
- Tsup — TypeScript bundler powered by esbuild
- Yarn from managing packages
- yarn build - Build the packageyarn dev
- - Run the package locallyyarn lint
- - Lint all files within this packageyarn test
- - Run all unit testsyarn test:report
- - Open the test coverage reportyarn test:update:snapshot
- - Run all unit tests and update the snapshot
Running yarn build from the root of the package will use tsup to compile the raw TypeScript and React code to plain JavaScript.
The /dist folder contains the compiled output.
`bash``
pagination
└── dist
├── index.d.ts <-- Types
├── index.js <-- CommonJS version
└── index.mjs <-- ES Modules version
...
Follows semantic versioning
Licensed under MIT License