import { Story, Preview, ArgsTable } from '@storybook/addon-docs/blocks';
import { Pagination } from './Pagination';

# Pagination

The pagination component is used to split data into chunks for the user. It can be used for tables to decide on the amount of rows to show.

<Preview>
  <Story id="inputs-pagination-table--default" />
</Preview>

## Uncontrolled change of amount of pages

You can use the `Pagination` component in a controlled mode by setting the `currentPage` prop.

When the `Pagination` is uncontrolled, there's an added behavior when changing the number of total items or items per page.
If `totalItems` or `itemsPerPage` props change in such a way that the number of pages change, the component will always go back to the first page.
This ensures that the current page is always on a page that exists.

To circumvent this behavior, provide a `currentPage` prop

## Props

<ArgsTable of={Pagination} />
