Skip to main content

Blazor Pagination

Use the Blazor Bootstrap Pagination component to show that related content spans several pages, with icons, disabled and active states, sizes, alignment and callback events.

Parameters​

NameTypeDefaultRequiredDescriptionAdded Version
ActivePageNumberint1Gets or sets the active page number.1.0.0
AlignmentAlignmentAlignment.NoneGets or sets the pagination alignment.1.0.0
DisplayPagesint5Gets or sets the maximum page links to be displayed.1.0.0
FirstLinkIconIconNameIconName.NoneGets or sets the first link icon.1.0.0
FirstLinkTextstringnullGets or sets the first link text. If 'FirstLinkIcon' is specified, the icon is shown instead and 'FirstLinkText' is used as the link's accessible name (aria-label).1.0.0
LastLinkIconIconNameIconName.NoneGets or sets the last link icon.1.0.0
LastLinkTextstringnullGets or sets the last link text. If 'LastLinkIcon' is specified, the icon is shown instead and 'LastLinkText' is used as the link's accessible name (aria-label).1.0.0
NextLinkIconIconNameIconName.NoneGets or sets the next link icon.1.0.0
NextLinkTextstringnullGets or sets the next link text. If 'NextLinkIcon' is specified, the icon is shown instead and 'NextLinkText' is used as the link's accessible name (aria-label).1.0.0
PreviousLinkIconIconNameIconName.NoneGets or sets the previous link icon.1.0.0
PreviousLinkTextstringnullGets or sets the previous link text. If 'PreviousLinkIcon' is specified, the icon is shown instead and 'PreviousLinkText' is used as the link's accessible name (aria-label).1.0.0
SizePaginationSizePaginationSize.NoneGets or sets the pagination size.1.0.0
TotalPagesint0Gets or sets the total pages.1.0.0

Callback Events​

EventDescription
PageChangedThis event fires immediately when the page number is changed.

Examples​

Pagination​

We use a large block of connected links for our pagination, making links hard to miss and easily scalable - all while providing large hit areas. Pagination is built with list HTML elements so screen readers can announce the number of available links.

Pagination - Examples
<Pagination TotalPages="8" />
<Pagination TotalPages="10" />
<Pagination TotalPages="13" />
<Pagination TotalPages="25" />
<Pagination TotalPages="100" />

See demo here.

Working with icons​

When a link shows an icon, its text is not displayed but is still used as the link's accessible name, so screen readers announce First, Previous, Next and Last by default. Set FirstLinkText, PreviousLinkText, NextLinkText and LastLinkText to change or translate these labels.

Pagination - Working with icons
<Pagination ActivePageNumber="1"
TotalPages="15"
DisplayPages="5"
FirstLinkIcon="IconName.ChevronDoubleLeft"
PreviousLinkIcon="IconName.ChevronLeft"
NextLinkIcon="IconName.ChevronRight"
LastLinkIcon="IconName.ChevronDoubleRight" />

See demo here.

Disabled and active states​

Pagination - Disabled and active states
<Pagination ActivePageNumber="1" TotalPages="10" />
<Pagination ActivePageNumber="3" TotalPages="10" />
<Pagination ActivePageNumber="5" TotalPages="10" />

See demo here.

Sizing​

Fancy larger or smaller pagination? Add Size="PaginationSize.Small" or Size="PaginationSize.Large" for additional sizes.

Pagination - Sizing
<Pagination ActivePageNumber="5" TotalPages="5" Size="PaginationSize.Small" />
<Pagination ActivePageNumber="5" TotalPages="5" />
<Pagination ActivePageNumber="5" TotalPages="5" Size="PaginationSize.Large" />

See demo here.

Alignment​

Pagination - Alignment
<Pagination ActivePageNumber="2" TotalPages="5" />
<Pagination ActivePageNumber="2" TotalPages="5" Alignment="Alignment.Center" />
<Pagination ActivePageNumber="2" TotalPages="5" Alignment="Alignment.End" />

See demo here.

Callback Events​

Pagination - Callback Events
<Pagination ActivePageNumber="@currentPageNumber"
TotalPages="10"
PageChanged="OnPageChangedAsync" />

<text>Current Page Number: @currentPageNumber</text>
@code {
int currentPageNumber = 2;

private async Task OnPageChangedAsync(int newPageNumber)
{
await Task.Run(() => { currentPageNumber = newPageNumber; });
}
}

See demo here.

More libraries from the team

Free, open-source .NET libraries built by the same team.

UnlimitedPDF

A pure .NET library to create, merge and split PDFs, and convert HTML to PDF.

BlazorExpress.ChartJS

Chart.js charts for Blazor, configured in C#.

BlazorExpress.Bulma

Enterprise-class Blazor components built on the Bulma CSS framework.