Skip to content
h v3.13.3
Search the docs
Find a component, section or page.

Pagination

Pagination with page navigation, next and previous links.

Installation

pnpm add @heyramzi/ui bits-ui

Usage

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

ref bindable HTMLElement | null
Default null
class string
count number
Default 0
perPage number
Default 10
page bindable number
Default 1
siblingCount number
Default 1
...rest
Every prop of Pagination.Root from bits-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

ref bindable HTMLUListElement | null
Default null
class string
children Snippet
...rest
Every prop of HTMLAttributes<HTMLUListElement> from svelte/elements
Prop Type Default
ref bindable HTMLUListElement | null null
class string
children Snippet
...rest Every prop of HTMLAttributes<HTMLUListElement> from svelte/elements

Pagination.Item

ref bindable HTMLLiElement | null
Default null
children Snippet
...rest
Every prop of HTMLLiAttributes from svelte/elements
Prop Type Default
ref bindable HTMLLiElement | null null
children Snippet
...rest Every prop of HTMLLiAttributes from svelte/elements

Pagination.Previous

label string
Default "Previous"
The text beside the arrow from `sm` up. Name the button with `aria-label`.
ref bindable HTMLElement | null
Default null
class string
...rest
Every prop of Pagination.PrevButton from bits-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

ref bindable HTMLSpanElement | null
Default null
class string
...rest
Every prop of HTMLAttributes<HTMLSpanElement> from svelte/elements except children
Prop Type Default
ref bindable HTMLSpanElement | null null
class string
...rest Every prop of HTMLAttributes<HTMLSpanElement> from svelte/elements except children
size "sm" | "default" | "lg"
Default "default"
isActive required boolean
ref bindable HTMLElement | null
Default null
class string
page Pagination.Page
children Snippet
...rest
Every prop of Pagination.Page from bits-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

label string
Default "Next"
The text beside the arrow from `sm` up. Name the button with `aria-label`.
ref bindable HTMLElement | null
Default null
class string
...rest
Every prop of Pagination.NextButton from bits-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

ref bindable HTMLElement | null
Default null
class string
children Snippet
...rest
Every prop of Pagination.PrevButton from bits-ui
Prop Type Default
ref bindable HTMLElement | null null
class string
children Snippet
...rest Every prop of Pagination.PrevButton from bits-ui

Pagination.NextButton

ref bindable HTMLElement | null
Default null
class string
children Snippet
...rest
Every prop of Pagination.NextButton from bits-ui
Prop Type Default
ref bindable HTMLElement | null null
class string
children Snippet
...rest Every prop of Pagination.NextButton from bits-ui