Pagination
Pagination with page navigation, next and previous links.
Installation
pnpm add @heyramzi/ui bits-uiUsage
import * as Pagination from "@heyramzi/ui/shadcn/pagination";<Pagination.Root count={100} perPage={10}>
{#snippet children({ pages, currentPage })}
<Pagination.Content>
<Pagination.Item><Pagination.Previous /></Pagination.Item>
{#each pages as page (page.key)}
<Pagination.Item>
{#if page.type === "ellipsis"}
<Pagination.Ellipsis />
{:else}
<Pagination.Link {page} isActive={currentPage === page.value}>{page.value}</Pagination.Link>
{/if}
</Pagination.Item>
{/each}
<Pagination.Item><Pagination.Next /></Pagination.Item>
</Pagination.Content>
{/snippet}
</Pagination.Root>API reference
Pagination.Root
refbindableHTMLElement | null- Default
null classstringcountnumber- Default
0 perPagenumber- Default
10 pagebindablenumber- Default
1 siblingCountnumber- Default
1 ...rest- Every prop of
Pagination.Rootfrombits-ui
| Prop | Type | Default |
|---|---|---|
ref bindable | HTMLElement | null | null |
class | string | |
count | number | 0 |
perPage | number | 10 |
page bindable | number | 1 |
siblingCount | number | 1 |
...rest | Every prop of Pagination.Root from bits-ui | |
Pagination.Content
refbindableHTMLUListElement | null- Default
null classstringchildrenSnippet...rest- Every prop of
HTMLAttributes<HTMLUListElement>fromsvelte/elements
| Prop | Type | Default |
|---|---|---|
ref bindable | HTMLUListElement | null | null |
class | string | |
children | Snippet | |
...rest | Every prop of HTMLAttributes<HTMLUListElement> from svelte/elements | |
Pagination.Item
refbindableHTMLLiElement | null- Default
null childrenSnippet...rest- Every prop of
HTMLLiAttributesfromsvelte/elements
| Prop | Type | Default |
|---|---|---|
ref bindable | HTMLLiElement | null | null |
children | Snippet | |
...rest | Every prop of HTMLLiAttributes from svelte/elements | |
Pagination.Previous
labelstring- Default
"Previous" - The text beside the arrow from `sm` up. Name the button with `aria-label`.
refbindableHTMLElement | null- Default
null classstring...rest- Every prop of
Pagination.PrevButtonfrombits-ui
| Prop | Type | Default |
|---|---|---|
label The text beside the arrow from `sm` up. Name the button with `aria-label`. | string | "Previous" |
ref bindable | HTMLElement | null | null |
class | string | |
...rest | Every prop of Pagination.PrevButton from bits-ui | |
Pagination.Ellipsis
refbindableHTMLSpanElement | null- Default
null classstring...rest- Every prop of
HTMLAttributes<HTMLSpanElement>fromsvelte/elementsexceptchildren
| Prop | Type | Default |
|---|---|---|
ref bindable | HTMLSpanElement | null | null |
class | string | |
...rest | Every prop of HTMLAttributes<HTMLSpanElement> from svelte/elements except children | |
Pagination.Link
size"sm" | "default" | "lg"- Default
"default" isActiverequiredbooleanrefbindableHTMLElement | null- Default
null classstringpagePagination.PagechildrenSnippet...rest- Every prop of
Pagination.Pagefrombits-ui
| Prop | Type | Default |
|---|---|---|
size | "sm" | "default" | "lg" | "default" |
isActive required | boolean | |
ref bindable | HTMLElement | null | null |
class | string | |
page | Pagination.Page | |
children | Snippet | |
...rest | Every prop of Pagination.Page from bits-ui | |
Pagination.Next
labelstring- Default
"Next" - The text beside the arrow from `sm` up. Name the button with `aria-label`.
refbindableHTMLElement | null- Default
null classstring...rest- Every prop of
Pagination.NextButtonfrombits-ui
| Prop | Type | Default |
|---|---|---|
label The text beside the arrow from `sm` up. Name the button with `aria-label`. | string | "Next" |
ref bindable | HTMLElement | null | null |
class | string | |
...rest | Every prop of Pagination.NextButton from bits-ui | |
Pagination.PrevButton
refbindableHTMLElement | null- Default
null classstringchildrenSnippet...rest- Every prop of
Pagination.PrevButtonfrombits-ui
| Prop | Type | Default |
|---|---|---|
ref bindable | HTMLElement | null | null |
class | string | |
children | Snippet | |
...rest | Every prop of Pagination.PrevButton from bits-ui | |
Pagination.NextButton
refbindableHTMLElement | null- Default
null classstringchildrenSnippet...rest- Every prop of
Pagination.NextButtonfrombits-ui
| Prop | Type | Default |
|---|---|---|
ref bindable | HTMLElement | null | null |
class | string | |
children | Snippet | |
...rest | Every prop of Pagination.NextButton from bits-ui | |