Pagination

带有上一页和下一页按钮的分页导航,标出当前页并以省略号代替跳过的页面——既可自由组合链接,也可使用按页数驱动的现成组件。

可用框架
  • Angular: 可用
  • Vue: 可用
  • React: 可用
  • React Native: 可用

用法

Showing page 5 of 12

导入

ts
import {
  SonePaginationComponent,
  SonePaginationContentDirective,
  SonePaginationEllipsisComponent,
  SonePaginationItemDirective,
  SonePaginationLinkDirective,
  SonePaginationNavDirective,
  SonePaginationNextComponent,
  SonePaginationPreviousComponent,
} from "@surface-one/angular/pagination";

API 参考

SonePaginationComponent组件

`<sone-pagination>` — page buttons drawn from a page count: Previous, the first and last pages, `siblings` pages around the current one with ellipses for the gaps, and Next. Two-way `[(page)]` (1-based); the count is `pageCount`, or `total` items at `pageSize` a page.

选择器
sone-pagination
输入
名称类型 默认值
page双向

The current page, 1-based.

number1
total

How many items there are; with `pageSize` it gives the page count.

number0
pageSizenumber10
pageCount

The page count, when you know it (wins over `total` / `pageSize`).

number | nullnull
siblings

Pages shown on each side of the current one.

number1
boundaries

Pages always shown at each end.

number1
disabledbooleanfalse
aria-label—$localize`:Pagination navigation:Pagination`
previousLabel—$localize`:Previous page button:Previous`
nextLabel—$localize`:Next page button:Next`

SonePaginationContentDirective指令

`ul[sonePaginationContent]` — the row of page links.

选择器
ul[sonePaginationContent]

SonePaginationEllipsisComponent组件

`<sone-pagination-ellipsis>` — stands in for hidden pages; says “More pages” to screen readers.

选择器
sone-pagination-ellipsis
输入
名称类型 默认值
srOnlyText

What screen readers hear in place of the hidden pages.

—$localize`More pages`

SonePaginationItemDirective指令

`li[sonePaginationItem]` — one link, previous / next or an ellipsis.

选择器
li[sonePaginationItem]

SonePaginationLinkDirective指令

`a[sonePaginationLink]` / `button[sonePaginationLink]` — a page: a ghost icon button, outlined with `aria-current="page"` when `isActive`. Add `routerLink` or `href`.

选择器
a[sonePaginationLink], button[sonePaginationLink]
输入
名称类型 默认值
isActive

The current page: outlined, `aria-current="page"`.

booleanfalse
sizeButtonSize"icon"

SonePaginationNavDirective指令

`nav[sonePaginationNav]` — the shadcn/ui Pagination root, for pages you lay out yourself (`<sone-pagination>` draws them from a page count). Named "Pagination" by default; set `aria-label` to name it otherwise.

选择器
nav[sonePaginationNav]
输入
名称类型 默认值
aria-label—$localize`:Pagination navigation:Pagination`

SonePaginationNextComponent组件

`a[sonePaginationNext]` / `button[…]` — goes on a page: “Next” and a chevron.

选择器
a[sonePaginationNext], button[sonePaginationNext]
输入
名称类型 默认值
label

The visible text (projected content replaces it).

—$localize`:Next page button:Next`
aria-label—$localize`Go to next page`

SonePaginationPreviousComponent组件

`a[sonePaginationPrevious]` / `button[…]` — goes back a page: a chevron and “Previous”.

选择器
a[sonePaginationPrevious], button[sonePaginationPrevious]
输入
名称类型 默认值
label

The visible text (projected content replaces it).

—$localize`:Previous page button:Previous`
aria-label—$localize`Go to previous page`