- Label
- Icon label
- Field
- Form
- Frontmatter form
- Questionnaire
- Input
- Input group
- Input OTP
- Password input
- Password strength
- Code input
- Number field
- Tag input
- Textarea
- Checkbox
- Radio group
- Language toggle group
- Emoji appearance toggle group
- Emoji picker
- Avatar picker
- AI provider picker
- Select
- Native select
- Combobox
- Language combobox
- Slider
- Calendar
- Switch
- Alert
- Avatar
- Badge
- Card
- AI provider card
- Model info card
- Model list
- Empty
- Item
- Tree item
- File tree
- Icon media
- File type icon
- Font preview
- Image preview
- Kbd
- Table
- Data table
- Data table column header
- Chart
- Code Block
- Code card
- Markdown view
- Attachment
- Bubble
- Marker
- Message
- Chat message
- Chat suggestion item
- Message scroller
- Trace
- Progress
- Spinner
- Sonner
- Toast
- Unsaved changes toolbar
- Unsaved indicator
- Status indicator
- Permission card
- Separator
- Skeleton
- Animated grid pattern
- Meteors
The pages of a long list, with the current page marked and links to the previous and next.
Installation#
pnpm dlx shadcn@latest add @zui/paginationThe CLI writes components/ui/pagination.tsx, installs Direction, Button,
Icon and Utils, and adds lucide-react-native.
Usage#
import {
Pagination,
PaginationContent,
PaginationEllipsis,
PaginationItem,
PaginationLink,
PaginationNext,
PaginationPrevious,
} from '@/components/ui/pagination';
import { Text } from '@/components/ui/text';<Pagination>
<PaginationContent>
<PaginationItem>
<PaginationPrevious onPress={() => setPage(page - 1)} />
</PaginationItem>
<PaginationItem>
<PaginationLink isActive>
<Text>1</Text>
</PaginationLink>
</PaginationItem>
<PaginationItem>
<PaginationLink onPress={() => setPage(2)}>
<Text>2</Text>
</PaginationLink>
</PaginationItem>
<PaginationItem>
<PaginationEllipsis />
</PaginationItem>
<PaginationItem>
<PaginationNext onPress={() => setPage(page + 1)} />
</PaginationItem>
</PaginationContent>
</Pagination>API reference#
Pagination#
Takes every prop of React Native's View. It is a navigation landmark named Pagination, centred in its row;
pass aria-label to name it otherwise.
PaginationContent, PaginationItem#
Each takes every prop of React Native's View. PaginationContent is a list laid out in a row, and each
PaginationItem is a listitem.
PaginationLink#
Takes every prop of Button but variant, plus:
| Prop | Type | Default |
|---|---|---|
isActive | boolean | false |
size | the Button's size | 'icon' |
It is announced as a link, and onPress navigates. The current page, isActive, is outlined, announced as
selected on iOS and Android, and carries aria-current="page" on the web; the others are ghost. Its number
goes in as a Text child.
PaginationPrevious, PaginationNext#
Each takes the props of PaginationLink but children. They draw a chevron, named Go to previous page and Go
to next page.
PaginationEllipsis#
Takes every prop of React Native's View. It draws three dots for the pages left out, and is hidden from
screen readers.
Right to left#
The previous and next chevrons are mirrored when Direction says text
reads right to left, so each points the way it goes, as upstream's cn-rtl-flip does.
Differences from upstream#
- Upstream's Previous and Next show a label from the
smbreakpoint up and the chevron alone below it. A phone is below it, so the native ones draw the chevron alone and take notext. - iOS and Android have no current-page state, so a screen reader there announces the current page as a
selected link. On the web it carries
aria-current="page", as upstream's does. - Upstream renders each link as an anchor with an
href. The native link navigates throughonPress.