Pagination
daisyUI v5 dropped the old DPagination computes the window (+ ellipses) in pure C#, so it
renders identically in static SSR.
Driving a table slice— @bind-Page + Skip/Take
| # | Item |
|---|---|
| 1 | Widget #1 |
| 2 | Widget #2 |
| 3 | Widget #3 |
| 4 | Widget #4 |
| 5 | Widget #5 |
| 6 | Widget #6 |
page 1 of 6
<DTable Zebra="true" Class="mb-4">
<thead>
<tr><th>#</th><th>Item</th></tr>
</thead>
<tbody>
@foreach (var item in _items.Skip((_page - 1) * _pageSize).Take(_pageSize))
{
<tr><td>@item.Id</td><td>@item.Name</td></tr>
}
</tbody>
</DTable>
<div class="flex items-center gap-4 flex-wrap">
<DPagination @bind-Page="_page" PageCount="@PageCount" />
<span class="text-sm opacity-70">page @_page of @PageCount</span>
</div>
@code {
private int _page = 1;
private const int _pageSize = 6;
private sealed record DemoItem(int Id, string Name);
private static readonly List<DemoItem> _items =
Enumerable.Range(1, 34).Select(i => new DemoItem(i, $"Widget #{i}")).ToList();
private int PageCount => (int)Math.Ceiling(_items.Count / (double)_pageSize);
}Sizes & options
<DPagination Page="3" PageCount="12" Size="DaisySize.ExtraSmall" />
<DPagination Page="3" PageCount="12" Size="DaisySize.Small" Color="DaisyColor.Primary" />
<DPagination Page="7" PageCount="12" />
<DPagination Page="3" PageCount="30" MaxButtons="3" Color="DaisyColor.Accent" />
<DPagination Page="2" PageCount="6" ShowPrevNext="false" Size="DaisySize.Large" />Tips
- Ellipses appear whenever the window hides pages; first and last page are always reachable.
- The active page gets
btn-active +aria-current="page" ; out-of-range buttons aredisabled . - Window logic is a pure static function — unit tested without rendering.
API
DPagination
Parameters
| Name | Type | Default | Binding | Description |
|---|---|---|---|---|
| Page | int | 1 | @bind-Page | Current page (1-based) — use with @bind-Page . |
| PageCount | int | 1 | — | Total number of pages. |
| MaxButtons | int | 5 | — | Maximum number of numbered slots before ellipses kick in. |
| Size | DaisySize | Medium | — | Button size (btn-xs ... btn-lg). ExtraSmallSmallMediumLargeExtraLarge |
| Color | DaisyColor | Default | — | Color for all buttons (the active page additionally gets btn-active ). DefaultPrimarySecondaryAccentInfoSuccessWarningErrorGhostNeutral |
| ShowPrevNext | bool | True | — | Show the « and » buttons. |
| PrevText | string | « | — | Label of the previous button. |
| NextText | string | » | — | Label of the next button. |
| EllipsisText | string | … | — | Label rendered in ellipse slots. |
| Class | string | — | — | Additional CSS classes appended to the component's computed daisyUI classes. |
| Style | string | — | — | Inline styles applied to the root element. |
DTable
Parameters
| Name | Type | Default | Binding | Description |
|---|---|---|---|---|
| Zebra | bool | False | — | Alternating row background ( table-zebra ). |
| PinRows | bool | False | — | Sticky header row(s) ( table-pin-rows ). |
| PinCols | bool | False | — | Sticky first column ( table-pin-cols ). |
| Size | DaisySize | Medium | — | Density: table-xs / table-sm / table-lg (Medium = daisy default). ExtraSmallSmallMediumLargeExtraLarge |
| ChildContent | RenderFragment | — | — | The table markup (caption, thead, tbody, ...). |
| Class | string | — | — | Additional CSS classes appended to the component's computed daisyUI classes. |
| Style | string | — | — | Inline styles applied to the root element. |