# Pagination URL: /react/components/pagination Source: https://github.com/daangn/seed-design/blob/dev/docs/content/react/components/pagination.mdx A component used to navigate to a desired page in a list divided into multiple pages. 사용 가능 버전: @seed-design/react-pagination@1.0.0, @seed-design/css@2.6.0 ## Preview ```tsx import { Pagination } from "seed-design/ui/pagination"; export default function PaginationPreview() { return ; } ``` ## Installation - npm: npx @seed-design/cli@latest add ui:pagination - pnpm: pnpm dlx @seed-design/cli@latest add ui:pagination - yarn: yarn dlx @seed-design/cli@latest add ui:pagination - bun: bun x @seed-design/cli@latest add ui:pagination ## Usage ```tsx import { Pagination } from "seed-design/ui/pagination"; ``` `totalPages` is the total number of pages, 0 or greater. If there are 0 or 1 pages, Pagination is not displayed. If the screen width is 480px or more, a maximum of 9 slots including previous/next buttons and ellipsis are displayed; if narrower, a maximum of 7 slots are displayed. The page area on small screens maintains 5 slots, and the first and last pages are displayed only in necessary ranges so you can directly select pages before and after the current page. The previous button is hidden on the first page and the next button is hidden on the last page, but the width of each area is maintained. Therefore, the position of the remaining buttons does not change even around the first and last pages. Place it at the bottom center of a general list or search results divided into multiple pages. If you need to control both the number of rows per page and the display range in a data table, use [Table Pagination](/react/components/table-pagination). ## Localization Modify `numberFormatter` and `paginationText` at the top of the snippet file to match your app's language. You can change not only number formats but also the root, previous/next buttons, and accessibility names of individual pages here. ## Props ## Examples ### Controlled You can control the page state externally using `page` and `onPageChange`. Handle loading of the changed list, focus movement, and result guidance in the list area, not in Pagination. ```tsx "use client"; import { Text, VStack } from "@seed-design/react"; import { useState } from "react"; import { Pagination } from "seed-design/ui/pagination"; export default function PaginationControlled() { const [page, setPage] = useState(5); return ( 현재 페이지: {page} ); } ``` ### onPageChange Details The second argument of `onPageChange` provides `reason` indicating the cause of change and `previousPage` being the page before change. | reason | Condition | | ------------ | -------------------------------------------------------------------- | | `page-item` | When a page number is selected | | `previous` | When the previous page button is selected | | `next` | When the next page button is selected | | `constraint` | When an externally provided page is out of valid range and corrected | When an external page is out of range, the corrected page is rendered first, and then the `constraint` change is notified once. ## Accessibility The root is rendered as `nav` and the default accessibility name is `Page navigation`. If there are multiple Paginationcomponents on the same screen, distinguish them using `aria-label` or `aria-labelledby`. The current page button has `aria-current="page"` applied. Keyboard users can move between buttons with Tab and select pages with Enter or Space.