Pagination
Page navigator on bits-ui Pagination. Renders prev/next, numbered links, and ellipsis — motion stays out of the way, the active link simply swaps to the outline button variant.
Usage
pagination.svelte
<script lang="ts">
import { Pagination as PaginationPrimitive } from 'bits-ui';
import { cn } from '$lib/utils.js';
let {
ref = $bindable(null),
class: className,
count = 0,
perPage = 10,
page = $bindable(1),
siblingCount = 1,
...restProps
}: PaginationPrimitive.RootProps = $props();
</script>
<PaginationPrimitive.Root
bind:ref
bind:page
role="navigation"
aria-label="pagination"
data-slot="pagination"
{count}
{perPage}
{siblingCount}
class={cn('mx-auto flex w-full justify-center', className)}
{...restProps}
/>
Controlled page
Bind page to drive pagination from the outside.
Current page: 3
pagination.svelte
<script lang="ts">
import { Pagination as PaginationPrimitive } from 'bits-ui';
import { cn } from '$lib/utils.js';
let {
ref = $bindable(null),
class: className,
count = 0,
perPage = 10,
page = $bindable(1),
siblingCount = 1,
...restProps
}: PaginationPrimitive.RootProps = $props();
</script>
<PaginationPrimitive.Root
bind:ref
bind:page
role="navigation"
aria-label="pagination"
data-slot="pagination"
{count}
{perPage}
{siblingCount}
class={cn('mx-auto flex w-full justify-center', className)}
{...restProps}
/>
Pagination.Root props
Inherits bits-ui Pagination.Root props. Use the children snippet to render pages and ellipses.
| Prop | Type | Default | Description |
|---|---|---|---|
number | 0 | Total number of items to paginate. | |
number | 10 | Items per page. Drives the total page count. | |
number (bindable) | 1 | Controlled current page. Two-way bindable. | |
number | 1 | How many pages to show on either side of the current page before an ellipsis. | |
boolean | false | When true, keyboard navigation wraps past the ends. |
Pagination.Link props
| Prop | Type | Default | Description |
|---|---|---|---|
Page | — | Page descriptor from the Root children snippet. | |
boolean | — | Marks the link as the current page. Applies the outline button variant and aria-current. | |
'default' | 'xs' | 'sm' | 'lg' | 'icon' | 'icon-xs' | 'icon-sm' | 'icon-lg' | 'icon' | Size token forwarded to the Button variant. |