Installation
npx logic2b@next add paginationUsage
import {
Pagination,
PaginationContent,
PaginationItem,
PaginationLink,
PaginationNext,
PaginationPrevious,
} from "@/components/ui/pagination"
<Pagination>
<PaginationContent>
<PaginationItem>
<PaginationPrevious href="#" />
</PaginationItem>
<PaginationItem>
<PaginationLink href="#">1</PaginationLink>
</PaginationItem>
<PaginationItem>
<PaginationNext href="#" />
</PaginationItem>
</PaginationContent>
</Pagination>
Usage notes
Pagination is a set of styled elements — the parts are plain nav, ul,
li, and a wrappers, so they accept the usual HTML attributes (href,
onClick, etc.).
Examples
Previous / next only
With ellipsis
Live playground
Edit the component props and inspect the exact JSX before copying it. The preview loads only when this section enters the viewport.
Generated JSX
<Pagination
className="justify-center"
>
<PaginationContent>
<PaginationItem>
<PaginationPrevious
href="#"
/>
</PaginationItem>
<PaginationItem>
<PaginationLink
href="#"
>1</PaginationLink>
</PaginationItem>
<PaginationItem>
<PaginationLink
href="#"
isActive
>2</PaginationLink>
</PaginationItem>
<PaginationItem>
<PaginationLink
href="#"
>3</PaginationLink>
</PaginationItem>
<PaginationItem>
<PaginationNext
href="#"
/>
</PaginationItem>
</PaginationContent>
</Pagination>API reference
Generated from the public TypeScript exports in src/ui/pagination.tsx.
Pagination
ComponentProps: React.ComponentProps<"nav">PaginationContent
ComponentProps: React.ComponentProps<"ul">PaginationLink
ComponentProps: PaginationLinkProps| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
isActive | boolean | No | — | — |
size | null | "default" | "sm" | "lg" | "icon" | No | "icon" | — |
PaginationItem
ComponentProps: React.ComponentProps<"li">PaginationPrevious
ComponentProps: React.ComponentProps<typeof PaginationLink>PaginationNext
ComponentProps: React.ComponentProps<typeof PaginationLink>PaginationEllipsis
ComponentProps: React.ComponentProps<"span">Accessibility contract
Machine-readable behavior and consumer responsibilities for pagination.
- Support
- Composition contract
- Pattern
- pagination navigation
- HTML nav/anchor/button
| Keys | Behavior |
|---|---|
| Enter Space | Activate the focused control. |
Built-in semantics
- The root is a navigation landmark and the active page can expose aria-current=page.
Consumer responsibilities
- Give the nav an aria-label and accessible labels to previous/next/icon-only links.