Numbered Pagination
A numbered page strip that collapses long runs to an ellipsis.
6 个框架中级
A "Showing 11–20 of 240" readout paired with previous and next links.
<nav aria-label="Pagination" class="flex w-full max-w-md flex-col items-center gap-3 sm:flex-row sm:justify-between">
<p class="m-0 text-sm tabular-nums text-gray-600 dark:text-gray-400" role="status" aria-live="polite">
Showing <span class="font-medium text-gray-900 dark:text-gray-100">11–20</span> of <span class="font-medium text-gray-900 dark:text-gray-100">240</span>
</p>
<div class="flex items-center gap-2">
<a href="?page=1" rel="prev" class="inline-flex h-10 items-center rounded-lg border border-gray-300 px-3 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-100 hover:text-gray-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 focus-visible:ring-offset-white motion-reduce:transition-none dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800 dark:hover:text-gray-100 dark:focus-visible:ring-blue-400 dark:focus-visible:ring-offset-gray-900">Previous</a>
<a href="?page=3" rel="next" class="inline-flex h-10 items-center rounded-lg border border-gray-300 px-3 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-100 hover:text-gray-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 focus-visible:ring-offset-white motion-reduce:transition-none dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800 dark:hover:text-gray-100 dark:focus-visible:ring-blue-400 dark:focus-visible:ring-offset-gray-900">Next</a>
</div>
</nav>| Prop | 类型 | 默认值 | 说明 |
|---|---|---|---|
currentPage必填 | number | - | 当前页码,从 1 开始。 |
pageSize必填 | number | - | 每页显示的项目数量。 |
totalItems必填 | number | - | 所有页面的项目总数。 |
buildHref必填 | (page: number) => string | - | 根据页码生成 URL,使分页保持为真实链接。 |
ariaLabel | string | 'Pagination' | 按钮的无障碍名称。仅有图标的按钮必须设置。 |
className | string | - | 合并到根元素上的额外类名。 |
The range is derived from `currentPage` and `pageSize` on every render rather than stored, so it can never drift from the page it describes. It sits in a polite live region so the count is re-announced after a client-side navigation. On a phone the readout stacks above the controls; from `sm` up they sit on one row, justified apart. `totalItems === 0` guards the first index so an empty list reads "0" rather than "1".