Pagination
Displays data in paged format and provides navigation between pages.
Preview
Installation
npx sigma-ui@latest add paginationUsage
<script setup lang="ts">
import {
Pagination,
PaginationEllipsis,
PaginationList,
PaginationListItem,
PaginationNext,
PaginationPrev,
} from '@/components/ui/pagination';
import { Button } from '@/components/ui/button';
</script>
<template>
<Pagination
v-slot="{ page }"
:total="100"
:items-per-page="10"
:default-page="1"
>
<PaginationList
v-slot="{ items }"
class="flex items-center gap-1"
>
<PaginationPrev />
<template v-for="(item, index) in items">
<PaginationListItem
v-if="item.type === 'page'"
:key="index"
:value="item.value"
as-child
>
<Button :variant="item.value === page ? 'default' : 'outline'">
{{ item.value }}
</Button>
</PaginationListItem>
<PaginationEllipsis
v-else
:key="item.type"
:index="index"
/>
</template>
<PaginationNext />
</PaginationList>
</Pagination>
</template>totalanditemsPerPageset the number of pages. Usev-model:pageto control the current page, ordefaultPageto set the initial one.PaginationListexposes theitemsto render, either pages or ellipses.siblingCountsets how many pages are shown around the current one.
Examples
With First and Last Buttons
Add PaginationFirst and PaginationLast to jump to the edges, and show-edges to always display the first and last pages.
<template>
<Pagination
v-slot="{ page }"
:total="100"
:items-per-page="10"
:sibling-count="1"
show-edges
:default-page="2"
>
<PaginationList
v-slot="{ items }"
class="flex items-center gap-1"
>
<PaginationFirst />
<PaginationPrev />
<template v-for="(item, index) in items">
<PaginationListItem
v-if="item.type === 'page'"
:key="index"
:value="item.value"
as-child
>
<Button
class="w-10 h-10 p-0"
:variant="item.value === page ? 'default' : 'outline'"
>
{{ item.value }}
</Button>
</PaginationListItem>
<PaginationEllipsis
v-else
:key="item.type"
:index="index"
/>
</template>
<PaginationNext />
<PaginationLast />
</PaginationList>
</Pagination>
</template>API Reference
PaginationEllipsis
Props
| Prop | Type | Default |
|---|---|---|
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
PaginationFirst
Props
| Prop | Type | Default |
|---|---|---|
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | true |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
PaginationLast
Props
| Prop | Type | Default |
|---|---|---|
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | true |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
PaginationNext
Props
| Prop | Type | Default |
|---|---|---|
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | true |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
PaginationPrev
Props
| Prop | Type | Default |
|---|---|---|
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | true |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
Accessibility
Renders a <nav> landmark with native buttons for every page and control. Reka UI marks the current page with aria-current="page" and labels each page button.
| Key | Description |
|---|---|
| Tab | Moves focus to the next focusable element. |
| Shift + Tab | Moves focus to the previous focusable element. |
| Space | When focus is on a page or an arrow button, goes to that page. |
| Enter | When focus is on a page or an arrow button, goes to that page. |