# Pagination > Page navigation controls for paginated content Source: https://shellui.dev/docs/v0.4/components/navigation/pagination The Pagination component provides navigation controls for moving between pages of content. It displays page numbers, previous/next buttons, and handles page state. ## Installation ```bash shellui add pagination ``` ## Basic Usage ```razor @code { private int currentPage = 1; } ``` ## With Content Combine pagination with a data list: ```razor
@foreach (var item in GetPagedItems()) {

@item.Title

@item.Description

}
@code { private record Item(string Title, string Description); private const int pageSize = 3; private int currentPage = 1; private int totalPages => (int)Math.Ceiling(allItems.Count / (double)pageSize); private readonly List allItems = Enumerable.Range(1, 15) .Select(i => new Item($"Item {i}", $"Description for item {i}")) .ToList(); private List GetPagedItems() => allItems .Skip((currentPage - 1) * pageSize) .Take(pageSize) .ToList(); } ``` ## Dynamic Page Count Calculate total pages from data: ```razor @code { private int currentPage = 1; private int totalItems = 95; private int pageSize = 10; private async Task HandlePageChange(int page) { currentPage = page; await LoadData(); } private async Task LoadData() { // Fetch data for current page } } ``` ## Custom Styling ```razor @code { private int currentPage = 1; } ``` ## Composed from parts New in v0.4: give `Pagination` child content and build it from `PaginationContent`, `PaginationItem`, `PaginationLink`, `PaginationPrevious`, `PaginationNext` and `PaginationEllipsis`. You decide which page numbers to show, so long ranges can collapse into an ellipsis. ```razor 1 @if (page > 3) { } @for (var i = Math.Max(2, page - 1); i <= Math.Min(Total - 1, page + 1); i++) { var number = i; @number } @if (page < Total - 2) { } @Total @code { private const int Total = 12; private int page = 6; private void Go(int target) => page = Math.Clamp(target, 1, Total); } ``` Each link is a button with `OnClick`, or an anchor when you set `Href`, which suits pages that put the page number in the URL. ```razor 1 2 3 ``` ## API Reference | Property | Type | Default | Description | |----------|------|---------|-------------| | `CurrentPage` | `int` | `1` | The active page number | | `CurrentPageChanged` | `EventCallback` | — | Callback when page changes; use `@bind-CurrentPage` | | `OnPageChange` | `EventCallback` | — | Deprecated: use `@bind-CurrentPage`; `shellui migrate pagination` rewrites it | | `TotalPages` | `int` | `1` | Total number of pages | | `ChildContent` | `RenderFragment?` | `null` | Set to compose the pagination from parts; `CurrentPage` and `TotalPages` are then unused | | `Class` | `string?` | `null` | Additional CSS classes | | `ClassName` | `string` | `""` | Deprecated: use `Class` | ### Parts | Component | Parameters | Purpose | |-----------|------------|---------| | `PaginationContent` | `Class` | The list that holds the items | | `PaginationItem` | `Class` | One list item | | `PaginationLink` | `Href`, `IsActive`, `Size` (`icon` or `default`), `OnClick`, `Class` | A page link; `IsActive` marks the current page | | `PaginationPrevious` | `Href`, `OnClick`, `Class` | The Previous link | | `PaginationNext` | `Href`, `OnClick`, `Class` | The Next link | | `PaginationEllipsis` | `Class` | Stands in for skipped pages | ## Accessibility The Pagination component includes: - `nav` element with `aria-label="pagination"` - `aria-current="page"` on the active page - Keyboard navigable with Tab and Enter - Previous/Next buttons with `aria-label` - Disabled state for first/last page boundaries