Pagination
Moves between pages of a long list.
Set pageCount, and page with onPageChange to control it. The list’s function child gets
the page numbers to show, with gaps where pages are left out.
Dependencies
What it's built from and what's built from it in Base, read from the imports in its source.
| Uses | Buttonprimitive |
|---|---|
| Used by | Nothing yet. |
| Packages | @ui-sdk/core@0.1.0-beta.20@ui-sdk/react@0.1.0-beta.20lucide-react@1.73.0 |
Installation
Set the project up for Base once first, as Getting started shows. Then add it with the CLI, or by hand.
With the CLI
Manually
Install its packages:
Add the components it uses first, listed under Dependencies.
Then copy the source:
API reference
Generated from Base's types. Props marked ours are added here; the rest come from the ui-sdk part it wraps. Every part also accepts its element's native attributes.
Pagination
Page controls in a labelled navigation landmark. Set pageCount, and page with onPageChange to control it.
- boundaries
How many pages always show at each end.
Type number · Default 1
- className
Type string | ((state: NoInfer<PaginationState>) => string)
- controller
Pages it from anywhere. Create one with
createPaginationController().Type { getPage: () => number; getPageCount: () => number; setPage: (page: number, options?: PaginationChangeOptions) => boolean; next: (options?: PaginationChangeOptions) => boolean; previous: (options?: PaginationChangeOptions | undefined) => boolean; first: (options?: PaginationChangeOptions | u...
- debug
Logs every state change with its reason to the console, in development builds.
Type boolean
- defaultPage
The page it starts on, when uncontrolled.
Type number · Default 1
- disabled
Whether every page and step does nothing, like a step at its end. A controller still pages it.
Type boolean · Default false
- getHref
The URL of a page. With it, parts are links: they navigate, open in a new tab with a modifier key, and work before JavaScript loads. Without it, they're buttons.
Type (page: number) => string
- onPageChange
Runs when the page wants to change: a page link (
"item-press"), the Previous, Next, First or Last part, or a controller ("imperative").details.cancel()keeps the page, and stops a link from navigating.Type (page: number, details: ChangeDetails<PaginationPageChangeReason>) => void
- page
The current page, from 1. Pass it to control the pagination.
Type number
- pageCount
How many pages there are. Or pass
totalandpageSize.Type number
- pageSize
How many items fit on a page, with
total.Type number · Default 10
- render
Type RenderProp<NoInfer<PaginationState>>
- siblings
How many pages show on each side of the current one.
Type number · Default 1
- style
Type CSSProperties | ((state: NoInfer<PaginationState>) => CSSProperties)
- total
How many items there are, for
pageCountfrompageSize.Type number
PaginationEllipsis
Marks pages left out of the list.
- children
Content, or a function of the part's state that returns it.
Type ReactNode | ((state: {}) => ReactNode)
- className
Class names, or a function of the part's state that returns them.
Type string | ((state: {}) => string)
- render
Renders your own element: one that receives the part's props, or a function of the props and the state.
Type RenderProp<{}>
- style
Styles, or a function of the part's state that returns them.
Type CSSProperties | ((state: {}) => CSSProperties)
PaginationLink
A page number. The current one is outlined.
- children
Content, or a function of the part's state that returns it.
Type ReactNode | ((state: PaginationLinkState) => ReactNode)
- className
Class names, or a function of the part's state that returns them.
Type string | ((state: PaginationLinkState) => string)
- page*
The page the link goes to, from 1.
Type number
- render
Renders your own element: one that receives the part's props, or a function of the props and the state.
Type RenderProp<PaginationLinkState>
- style
Styles, or a function of the part's state that returns them.
Type CSSProperties | ((state: PaginationLinkState) => CSSProperties)
PaginationList
The row of controls. Pass a function child to render its items: page numbers and gaps.
- children
Content, or a function of the part's state that returns it.
Type ReactNode | ((state: NoInfer<PaginationState>) => ReactNode)
- className
Class names, or a function of the part's state that returns them.
Type string | ((state: NoInfer<PaginationState>) => string)
- render
Renders your own element: one that receives the part's props, or a function of the props and the state.
Type RenderProp<NoInfer<PaginationState>>
- style
Styles, or a function of the part's state that returns them.
Type CSSProperties | ((state: NoInfer<PaginationState>) => CSSProperties)
PaginationNext
Goes forward a page, with its chevron built in.
- children
Content, or a function of the part's state that returns it.
Type ReactNode | ((state: PaginationStepState) => ReactNode) · Default Next
- className
Class names, or a function of the part's state that returns them.
Type string | ((state: PaginationStepState) => string)
- render
Renders your own element: one that receives the part's props, or a function of the props and the state.
Type RenderProp<PaginationStepState>
- style
Styles, or a function of the part's state that returns them.
Type CSSProperties | ((state: PaginationStepState) => CSSProperties)
PaginationPrevious
Goes back a page, with its chevron built in.
- children
Content, or a function of the part's state that returns it.
Type ReactNode | ((state: PaginationStepState) => ReactNode) · Default Previous
- className
Class names, or a function of the part's state that returns them.
Type string | ((state: PaginationStepState) => string)
- render
Renders your own element: one that receives the part's props, or a function of the props and the state.
Type RenderProp<PaginationStepState>
- style
Styles, or a function of the part's state that returns them.
Type CSSProperties | ((state: PaginationStepState) => CSSProperties)