| Invoice | Status | Amount |
|---|---|---|
| INV-1211Fabrikam Inc | Due | $911.90 |
| INV-1212Tailspin Toys | Overdue | $991.09 |
| INV-1213Litware Labs | Paid | $1,070.28 |
| INV-1214Adventure Works | Paid | $1,149.47 |
| INV-1215Proseware | Due | $1,228.66 |
GhostPagination
GhostPagination navigates a bounded page sequence for tables and lists. Import it from @ghostvue/themes for the default control styling; the page logic and semantics come from the headless component in @ghostvue/vue. Fetching, totals, and URL sync stay outside the component. To style the controls yourself, see Advanced: headless composition.
Page through records
Themed invoice table whose pager changes both the current page and the visible range of records.
The pager sits in the card footer, below the rows it controls. v-model binds a 1-based page index, and the example slices five invoices for that page, so choosing Page 4 shows invoices 16–20. A polite status reads the new range once, and focus stays on the button that was pressed, so keyboard users can keep paging with Enter or Space. Each invoice number is a row header, and the table sits in a named scroll region so the narrowest phones scroll the rows instead of the page.
In a real app, fetch one page at a time and pass pageCount from the response's total. When modelValue is omitted, the component is uncontrolled and starts at defaultPage (default 1).
@ghostvue/themes adds these to the headless GhostPagination API, which it forwards:
| Prop | Type | Default | Description |
|---|---|---|---|
size | 'sm' | 'md' | 'lg' | "md" | Control sizing. Default omits data-size. |
Controlled state
Parent-owned page and page count that follow a themed events-per-page choice.
Here the parent owns both the page and pageCount. Changing Events per page changes the page count, so the example moves to the page that holds the first event that was on screen. That page is always within the new bounds. Passing :model-value with @update:model-value instead of v-model lets the parent decide whether to apply each change.
Ellipsis
Themed 40-page catalog that collapses hidden runs into start and end ellipses.
getPaginationRange (exported from @ghostvue/vue) builds the numbered range and ellipsis markers from siblingCount and boundaryCount (both default 1). With 40 pages, the pager keeps the first and last page and one page on each side of the current page. Ellipses mark the hidden runs and are not buttons; use Previous page and Next page, or a visible number, to move.
API
| Prop | Type | Default | Description |
|---|---|---|---|
ariaLabel | string | "Pagination" | aria-label on the nav root. |
boundaryCount | number | 1 | Pages pinned at each end. |
defaultPage | number | 1 | Initial page when uncontrolled. |
disabled | boolean | false | Disable every control. |
ellipsisLabel | string | "More pages" | Declared prop ellipsisLabel. |
firstLabel | string | "First page" | Declared prop firstLabel. |
getPageLabel | ((page: number) => string) | — | Declared prop getPageLabel. |
lastLabel | string | "Last page" | Declared prop lastLabel. |
modelValue | number | — | Controlled current page (1-based). |
nextLabel | string | "Next page" | Declared prop nextLabel. |
pageCount | number | Required | Total pages (≥ 1). |
previousLabel | string | "Previous page" | Declared prop previousLabel. |
showEdges | boolean | true | Render first and last controls. |
siblingCount | number | 1 | Pages beside the current page. |
| Slot | Slot props | Description |
|---|---|---|
ellipsis | placement: 'end' | 'start' | Named slot ellipsis. |
page | current: boolean, page: number | Named slot page. |
Native attributes fall through to the nav. Template refs expose element, focus(), and blur(). Optional slots: page and ellipsis.
Keyboard and focus
Each control stays in the native tab order (no roving tabindex). Enter / Space activate the focused button. Inactive edge controls use aria-disabled="true" so focus is not lost when a control becomes inactive. The current page is marked with aria-current="page" only. Native disabled is reserved for the whole component.
Advanced: headless composition
The headless component from @ghostvue/vue renders the same <nav> and buttons with no styles. Use it with your own control CSS, or reach for useGhostPagination to bind the contract to markup you already render.
Headless pager
Numbered page navigation with previous and next.
The root is a <nav> landmark. Numbered controls expose aria-current="page" on the active page. Edge controls use visible glyphs with configurable accessible names (firstLabel, previousLabel, nextLabel, lastLabel).
See also
GhostTable— the themed table the lead example pages through.GhostDataTable— sorting, selection, and paging built in.GhostButton— shared action semantics for custom layouts.- Specification