Keyframery

Pagination

One raised key glides between page numbers and the range count rolls.

See it as an AI agent does.

Resize preview. Focus the handle and use the left or right arrow keys. Hold Shift for larger steps.— px
Customize1 controls
Animation speed1×

Installation

npx shadcn@latest add @keyframery/pagination

This adds components/keyframery/pagination.tsx and its primitive to your project, and installs UI SDK. The motion tokens are added to your global CSS the first time you install a component.

Usage

import { Pagination, PaginationList } from "@/components/keyframery/pagination"

export default function Usage() {
  return (
    <Pagination aria-label="Pages" total={120} pageSize={10}>
      <PaginationList />
    </Pagination>
  )
}

Examples

Basic

Give it total and pageSize and it works out the pages, with ellipses for the long gaps.

getHref makes every page a real link, so each page has its own URL and works without JavaScript.

Rolling count

PaginationRoll rolls a number to its new value, for a “21 to 40 of 240” line.

Motion

MoveWhat you see
GlideOne raised key glides between page numbers.
RollThe range count rolls to the new numbers.
PressThe arrows press in.

Timing and springiness follow the motion style you set. To change how fast this pagination moves, pass speed:

<Pagination speed="fast">
  …
</Pagination>

"fast" is 0.6×, "slow" 1.4×, and a number sets the multiplier. With reduced motion turned on, nothing moves: changes happen at once or with a short fade.

Theming

Set these CSS variables on the component or a parent. Leave them unset to follow the light and dark theme. The open Customize panel below the preview lets you try these settings.

VariableWhat it changesDefault
--pagination-trackPagination well--muted
--pagination-keyCurrent page key--background, --accent in dark
--pagination-inkPage labels--muted-foreground
--pagination-selected-inkCurrent and hovered page--foreground
--pagination-sizePage height and least width2rem
--pagination-radiusWell corners12px
--pagination-key-radiusPage corners9px
--pagination-gapPage gap0.125rem

API reference

Every part takes className and children. Parts from UI SDK also take render, to draw your own element, and a function of their state for className and style. Props not listed here are in the UI SDK pagination reference.

Pagination

Renders a <div>, and takes its props too.

Prop

Type

Renders a <a>, and takes its props too.

Prop

Type

PaginationRoll

Renders a <span>, and takes its props too.

Prop

Type

Other parts

These take the props of the element they render, and nothing else:

  • PaginationList: a <ul>
  • PaginationEllipsis: a <span>
  • PaginationFirst: a <a>
  • PaginationItem: a <li>
  • PaginationLast: a <a>
  • PaginationNext: a <a>
  • PaginationPrevious: a <a>

Keyboard

KeyWhat it does
TabMoves between the page links.
EnterGoes to the focused page.

Accessibility

Keyboard, focus and screen-reader behaviour come from UI SDK and are not changed. More in Accessibility.

Swap the import

Already using UI SDK's pagination with your own styles? Keep your markup and change one line. The primitive adds motion and nothing else.

// Before
import { … } from "@ui-sdk/react/pagination"

// After: same parts, same props, now animated
import { … } from "@/components/keyframery/primitives/pagination"

Questions

How does the animated Pagination for UI SDK move?

Glide: One raised key glides between page numbers. Roll: The range count rolls to the new numbers. Press: The arrows press in.

Do I need Motion or Framer Motion for the animated Pagination?

No. Every move is plain CSS, so there is nothing to install besides the component and UI SDK.

Can I keep my own styling and only take the motion?

Yes. Import from @/components/keyframery/primitives/pagination instead. It has the same parts and props as @ui-sdk/react/pagination and adds motion only.

What happens to the Pagination when someone turns on reduced motion?

Nothing moves. State changes happen at once, or with a short fade.

All components

On this page