Default
The shadcn demo: Previous, three numbers with the second current, an ellipsis, Next. The current page is a block of highlighter; point at another and it wears the wash.
Page links as drawn buttons: each number is a Button around your own link, the page you are on is a block of highlighter, the arrows and the ellipsis are hand-drawn. It is just links, so it works with any router, or with plain hrefs and no JavaScript at all.
npx shadcn@latest add @wobko/pagination第一次使用?先把 registry 加进 components.json。 如何安装
The shadcn demo: Previous, three numbers with the second current, an ellipsis, Next. The current page is a block of highlighter; point at another and it wears the wash.
Nine pages with the classic windowing: the first and last always show, the current page has a neighbor on each side, the rest fold into ellipses. Previous is inert on page 1 and Next on page 9; the links have real hrefs, so open in a new tab works.
Previous, a line of text, Next: for a feed or a list you page through. Sizes are Button sizes; here the arrows are square icon buttons with a label of their own, and a load-more link uses the large size.
A real use: twenty-three notebooks, five to a page. The range under the table and the current number follow the page, and the links keep real hrefs for people who open them in a new tab.
Official `pagination-demo`, part for part. Only the hrefs differ: a bare `#` would send the docs router home, so each link points at an in-page anchor. The current page is a block of highlighter; the others wear it when pointed at.
A page link: `<Button asChild>` around an `<a>`, so it is drawn (ghost, or secondary when active) and keeps your `href`, `target` and handlers. `buttonVariants()` on a bare anchor would give layout without the drawing, which is why this wraps a Button.
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| isActive | boolean | false | The current page: a block of highlighter, `aria-current="page"`, `data-active`. |
| size | "default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | "icon" | A Button size. A page number is a square icon button. |
| disabled | boolean | false | For a link that goes nowhere (the first page's Previous): drawn dashed, `aria-disabled`, out of the tab order, its click swallowed (your onClick does not run). |
CLI 会复制进你项目的文件。
正在加载源码