Skip to content

Pagination

Page navigation component with previous, next, and page numbers.

...
Page 1 of 10

Installation

bash
npx @galaxy-stack/nebula-cli add pagination
bash
npx @galaxy-stack/nebula-cli add pagination
bash
npx @galaxy-stack/nebula-cli add pagination
bash
# If you have installed galaxy-design globally
galaxy-design add pagination

Usage

tsx
import { Pagination } from '@/components/pagination'

export default function PaginationDemo() {
  const [currentPage, setCurrentPage] = React.useState(1)
  const totalPages = 10

  return (
    <Pagination
      currentPage={currentPage}
      totalPages={totalPages}
      onPageChange={setCurrentPage}
    />
  )
}
vue
<script setup lang="ts">
import { ref } from 'vue'
import { Pagination } from '@/components/pagination'

const currentPage = ref(1)
const totalPages = 10

const handlePageChange = (page: number) => {
  currentPage.value = page
}
</script>

<template>
  <Pagination
    :current-page="currentPage"
    :total-pages="totalPages"
    @page-change="handlePageChange"
  />
</template>
typescript
import { Component } from '@angular/core'
import { PaginationComponent } from '@/components/pagination'

@Component({
  selector: 'app-pagination-demo',
  standalone: true,
  imports: [PaginationComponent],
  template: `
    <ui-pagination
      [currentPage]="currentPage"
      [totalPages]="totalPages"
      (pageChange)="handlePageChange($event)"
    />
  `
})
export class PaginationDemo {
  currentPage = 1
  totalPages = 10

  handlePageChange(page: number) {
    this.currentPage = page
  }
}

API Reference

Props

This component accepts the following props:

PropTypeDefaultDescription
............

Props

PropTypeDefaultDescription
currentPagenumber1The current active page (1-indexed)
totalPagesnumber1Total number of pages
siblingCountnumber1Number of page buttons to show on each side of current page
onPageChange(page: number) => void-Callback fired when page changes

Examples

With Custom Sibling Count

tsx
<Pagination
  currentPage={currentPage}
  totalPages={20}
  siblingCount={2}
  onPageChange={setCurrentPage}
/>
vue
<Pagination
  :current-page="currentPage"
  :total-pages="20"
  :sibling-count="2"
  @page-change="handlePageChange"
/>
typescript
<ui-pagination
  [currentPage]="currentPage"
  [totalPages]="20"
  [siblingCount]="2"
  (pageChange)="handlePageChange($event)"
/>

With Data Table

tsx
const itemsPerPage = 10
const totalItems = 100
const totalPages = Math.ceil(totalItems / itemsPerPage)

const paginatedData = data.slice(
  (currentPage - 1) * itemsPerPage,
  currentPage * itemsPerPage
)

return (
  <>
    <Table data={paginatedData} />
    <Pagination
      currentPage={currentPage}
      totalPages={totalPages}
      onPageChange={setCurrentPage}
    />
  </>
)

Accessibility

  • Uses semantic <nav> element with role="navigation"
  • Page buttons have aria-label describing their function
  • Current page has aria-current="page"
  • Disabled buttons have disabled attribute and reduced opacity

Author

Bùi Trọng Hiếu (kevinbui)

License

MIT © 2025 Bùi Trọng Hiếu (kevinbui)

Released under the MIT License.