icon

Morainev0.5.0

Pagination
navigationpagination

Pagination

Page navigation component with configurable sibling count and edge display.

Import#

import { Pagination } from 'moraine'

Slot Structure#

Page controls with previous, next, and numbered page link buttons.

root
└── list
├── item (prev)
│ └── prev (Button)
├── item (×n, page links)
│ └── link (Button)
└── item (next)
└── next (Button)

Examples#

Variants#

Render controls as links and override variant pairing when needed.

function Variants() {
return (
<Pagination
total={60}
itemsPerPage={10}
to={(nextPage) => `#pagination&page=${nextPage}`}
variant="outline"
activeVariant="default"
controlVariant="secondary"
/>
)
}

Sizes#

Size scale from xs to xl for page links and previous/next controls.

function Sizes() {
const SIZES = ['xs', 'sm', 'md', 'lg', 'xl'] as const
return (
<div class="space-y-4">
<For each={SIZES}>
{(size) => (
<div class="space-y-1">
<p class="text-xs text-muted-foreground font-mono">{size}</p>
<Pagination
size={size}
total={120}
itemsPerPage={10}
siblingCount={1}
prevText="Prev"
nextText="Next"
/>
</div>
)}
</For>
</div>
)
}

Controlled#

Default ghost + outline controls with external page state management.

function Controlled() {
const [page, setPage] = createSignal(3)
return (
<div class="space-y-3">
<Pagination
page={page()}
onPageChange={setPage}
total={120}
itemsPerPage={10}
siblingCount={1}
prevText="Previous"
nextText="Next"
/>
<p class="text-xs text-muted-foreground">Current page: {page()}</p>
</div>
)
}

Minimal#

Hide prev/next controls and show only page buttons.

function Minimal() {
return <Pagination total={80} itemsPerPage={10} showControls={false} />
}

API Reference#

Attributes#

Slotroot5 attributes
Navigation container for page controls.

Data Attributes

3
Data AttributeDescription
data-orientation
Stores the rendered orientation.
data-size
Stores the resolved size variant.
data-variant
Stores the resolved visual variant.

ARIA Attributes

2
ARIA AttributeDescription
aria-label
Provides an accessible label when visible text is not sufficient.
role
Defines the semantic role exposed to assistive technology.

Props#

PropTypeDefaultDescription
activeVariant"link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | undefinedoutline
Visual variant for the active page button.
classClassValue
Class applied to the component root or trigger element.
classesPaginationT.Classes | undefined
Slot-based class overrides.
controlVariant"link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | undefinedghost
Visual variant for the previous/next control buttons.
defaultPagenumber | undefined1
Initial page number when uncontrolled.
disabledboolean | undefined
Whether the pagination is disabled.
ellipsisIconIconT.Nameicon-ellipsis
Icon name for the ellipsis indicator.
itemsPerPagenumber | undefined10
Number of items to display per page.
nextIconIconT.Nameicon-chevron-right
Icon name for the next button.
nextTextstring | undefined
Text to display in the next button.
onPageChange((page: number) => void) | undefined
Callback triggered when the page changes.
pagenumber | undefined
Controlled current page number (1-indexed).
prevIconIconT.Nameicon-chevron-left
Icon name for the previous button.
prevTextstring | undefined
Text to display in the previous button.
refJSX.HTMLElementTags["nav"] extends { ref?: infer Ref; } ? Ref : never | undefined
showControlsboolean | undefinedtrue
Whether to show previous and next control buttons.
siblingCountnumber | undefined2
Number of page buttons to show on either side of the current page.
sizeFormFieldSize | undefinedmd
Size of the pagination buttons.
styleJSX.CSSProperties | undefined
stylesPaginationT.Styles | undefined
Slot-based style overrides.
to((page: number) => string | undefined) | undefined
Function to generate a destination URL for a given page number. If provided, pagination items will render as anchor tags.
totalnumber | undefined0
Total number of items across all pages.
variant"link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | undefinedghost
Visual variant for the page buttons.