# Pagination

Pagination with page navigation, next and previous links.

Section: Components / Navigation
Page: https://ui.heyramzi.com/components/pagination
Import path: `@heyramzi/ui/shadcn/pagination`

## Import

```ts
import * as Pagination from "@heyramzi/ui/shadcn/pagination";
```

## Usage

```svelte
<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>
```

## Demo

```svelte
<script lang="ts">
	import * as Pagination from "@heyramzi/ui/shadcn/pagination";
</script>

<Pagination.Root count={30} perPage={10} page={2}>
	{#snippet children({ pages, currentPage })}
		<Pagination.Content>
			<Pagination.Item>
				<Pagination.Previous />
			</Pagination.Item>
			{#each pages as page (page.key)}
				{#if page.type === "ellipsis"}
					<Pagination.Item>
						<Pagination.Ellipsis />
					</Pagination.Item>
				{:else}
					<Pagination.Item>
						<Pagination.Link {page} isActive={currentPage === page.value}>
							{page.value}
						</Pagination.Link>
					</Pagination.Item>
				{/if}
			{/each}
			<Pagination.Item>
				<Pagination.Ellipsis />
			</Pagination.Item>
			<Pagination.Item>
				<Pagination.Next />
			</Pagination.Item>
		</Pagination.Content>
	{/snippet}
</Pagination.Root>
```

## API

### Pagination.Root

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `ref` | `HTMLElement \| null` | `null` | bindable |
| `class` | `string` |  |  |
| `count` | `number` | `0` |  |
| `perPage` | `number` | `10` |  |
| `page` | `number` | `1` | bindable |
| `siblingCount` | `number` | `1` |  |

Every prop of `Pagination.Root` from `bits-ui`.

### Pagination.Content

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `ref` | `HTMLUListElement \| null` | `null` | bindable |
| `class` | `string` |  |  |
| `children` | `Snippet` |  |  |

Every prop of `HTMLAttributes<HTMLUListElement>` from `svelte/elements`.

### Pagination.Item

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `ref` | `HTMLLiElement \| null` | `null` | bindable |
| `children` | `Snippet` |  |  |

Every prop of `HTMLLiAttributes` from `svelte/elements`.

### Pagination.Previous

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `label` | `string` | `"Previous"` | The text beside the arrow from `sm` up. Name the button with `aria-label`. |
| `ref` | `HTMLElement \| null` | `null` | bindable |
| `class` | `string` |  |  |

Every prop of `Pagination.PrevButton` from `bits-ui`.

### Pagination.Ellipsis

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `ref` | `HTMLSpanElement \| null` | `null` | bindable |
| `class` | `string` |  |  |

Every prop of `HTMLAttributes<HTMLSpanElement>` from `svelte/elements`, except `children`.

### Pagination.Link

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `size` | `"sm"` \| `"default"` \| `"lg"` | `"default"` |  |
| `isActive` | `boolean` |  | required |
| `ref` | `HTMLElement \| null` | `null` | bindable |
| `class` | `string` |  |  |
| `page` |  |  |  |
| `children` | `Snippet` |  |  |

Every prop of `Pagination.Page` from `bits-ui`.

### Pagination.Next

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `label` | `string` | `"Next"` | The text beside the arrow from `sm` up. Name the button with `aria-label`. |
| `ref` | `HTMLElement \| null` | `null` | bindable |
| `class` | `string` |  |  |

Every prop of `Pagination.NextButton` from `bits-ui`.

### Pagination.PrevButton

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `ref` | `HTMLElement \| null` | `null` | bindable |
| `class` | `string` |  |  |
| `children` | `Snippet` |  |  |

Every prop of `Pagination.PrevButton` from `bits-ui`.

### Pagination.NextButton

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `ref` | `HTMLElement \| null` | `null` | bindable |
| `class` | `string` |  |  |
| `children` | `Snippet` |  |  |

Every prop of `Pagination.NextButton` from `bits-ui`.
