Outline paginations
Five pagination treatments where the border does the talking instead of a fill: an inset ring, dashed edges, a double border, a thick weight and a corner underline. Each carries its own page state, is sized, token-driven and marks the active page with aria-current.
Installation
The styled layer is free and installs like any other ai2 component.
Run the following command
npx shadcn@latest add @ai2/pagination-outlineDependencies, the @ai2/tokens theme and the component file are installed together.
Install dependencies
npm install motion lucide-reactCopy the source
components/ui/pagination-outline.tsx"use client"
import * as React from "react"
import { ChevronLeft, ChevronRight, MoreHorizontal } from "lucide-react"
import { motion, useReducedMotion } from "motion/react"
import { cn } from "@/lib/utils"
/* Outline pagination family: 5 edge-led paginators. The frame speaks instead of the fill: ring, dashed, double, thick and corner-marked. Colour comes only from semantic tokens; alpha through color-mix. The active page slides with a framer layoutId; the layoutId derives from React.useId(), so instances on the same page do not get mixed up. */
export type StyledSize = "sm" | "md" | "lg" | "xl"
const iconSize: Record<StyledSize, string> = {
sm: "size-8",
md: "size-9",
lg: "size-10",
xl: "size-12",
}
const focusRing =
"outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50"
const btnBase =
"relative inline-flex shrink-0 select-none items-center justify-center font-medium whitespace-nowrap transition-colors [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_i]:text-base [&_i]:leading-none"
interface PaginationProps {
className?: string
size?: StyledSize
total?: number
defaultPage?: number
}
/* Dahili sayfa durumu. */
function usePageState(total: number, defaultPage: number) {
const n = Math.max(total, 1)
const clamp = React.useCallback((p: number) => Math.min(Math.max(p, 1), n), [n])
const [current, setCurrent] = React.useState(() => clamp(defaultPage))
const goto = (p: number) => setCurrent(clamp(p))
return { current: clamp(current), total: n, goto }
}
function pageRange(current: number, total: number): (number | "ellipsis")[] {
if (total <= 7) return Array.from({ length: total }, (_, i) => i + 1)
const out: (number | "ellipsis")[] = [1]
const left = Math.max(2, current - 1)
const right = Math.min(total - 1, current + 1)
if (left > 2) out.push("ellipsis")
for (let p = left; p <= right; p++) out.push(p)
if (right < total - 1) out.push("ellipsis")
out.push(total)
return out
}
/* Shared shell: the frame technique arrives through the idle and active classes. The active emphasis stays unfilled, only the edge is painted. */
function OutlineShell({
props,
radius,
idleClassName,
activeClassName,
activeTextClassName,
arrowClassName,
}: {
props: PaginationProps
radius: string
idleClassName: string
activeClassName: string
activeTextClassName: string
arrowClassName: string
}) {
const { className, size = "md", total = 8, defaultPage = 1 } = props
const reduce = useReducedMotion()
const { current, total: n, goto } = usePageState(total, defaultPage)
const items = pageRange(current, n)
const uid = React.useId()
return (
<nav
data-slot="styled-pagination"
aria-label="Pagination"
className={cn("inline-flex items-center gap-1.5", className)}
>
<button
type="button"
aria-label="Go to previous page"
disabled={current <= 1}
onClick={() => goto(current - 1)}
className={cn(btnBase, focusRing, iconSize[size], radius, arrowClassName)}
>
<ChevronLeft />
</button>
{items.map((it, i) =>
it === "ellipsis" ? (
<span
key={`e${i}`}
aria-hidden="true"
className={cn(iconSize[size], "inline-flex items-center justify-center text-muted-foreground")}
>
<MoreHorizontal />
</span>
) : (
<button
key={it}
type="button"
aria-label={`Go to page ${it}`}
aria-current={it === current ? "page" : undefined}
onClick={() => goto(it)}
className={cn(
btnBase,
focusRing,
iconSize[size],
radius,
it === current ? activeTextClassName : idleClassName
)}
>
{it === current && (
<motion.span
layoutId={reduce ? undefined : `${uid}-outline-active`}
aria-hidden="true"
transition={reduce ? { duration: 0 } : { type: "spring" as const, stiffness: 500, damping: 34 }}
className={cn("absolute inset-0", radius, activeClassName)}
/>
)}
<span className="relative">{it}</span>
</button>
)
)}
<button
type="button"
aria-label="Go to next page"
disabled={current >= n}
onClick={() => goto(current + 1)}
className={cn(btnBase, focusRing, iconSize[size], radius, arrowClassName)}
>
<ChevronRight />
</button>
</nav>
)
}
/* Ring: the active page is ringed with a primary ring, no fill. */
export function RingPagination(props: PaginationProps) {
return (
<OutlineShell
props={props}
radius="rounded-full"
idleClassName="text-muted-foreground hover:text-foreground hover:bg-[color-mix(in_oklab,var(--color-foreground)_6%,transparent)]"
activeClassName="ring-2 ring-primary ring-inset bg-[color-mix(in_oklab,var(--color-primary)_10%,transparent)]"
activeTextClassName="text-foreground"
arrowClassName="border border-border text-foreground hover:bg-accent"
/>
)
}
/* Dashed: a dashed frame; on the active page the dashes turn primary. */
export function DashedPagination(props: PaginationProps) {
return (
<OutlineShell
props={props}
radius="rounded-lg"
idleClassName="border border-dashed border-border text-muted-foreground hover:border-[color-mix(in_oklab,var(--color-foreground)_35%,transparent)] hover:text-foreground"
activeClassName="border-2 border-dashed border-primary"
activeTextClassName="text-foreground"
arrowClassName="border border-dashed border-border text-foreground hover:bg-accent"
/>
)
}
/* Double: ic ve dis olmak uzere iki katmanli cerceve. */
export function DoublePagination(props: PaginationProps) {
return (
<OutlineShell
props={props}
radius="rounded-md"
idleClassName="border border-border text-muted-foreground hover:text-foreground hover:border-[color-mix(in_oklab,var(--color-foreground)_30%,transparent)]"
activeClassName="border border-primary ring-1 ring-primary ring-offset-2 ring-offset-background"
activeTextClassName="text-foreground"
arrowClassName="border border-border text-foreground hover:bg-accent"
/>
)
}
/* Thick: kalin, iddiali kenar. */
export function ThickPagination(props: PaginationProps) {
return (
<OutlineShell
props={props}
radius="rounded-lg"
idleClassName="border-2 border-[color-mix(in_oklab,var(--color-foreground)_18%,transparent)] text-muted-foreground hover:text-foreground hover:border-[color-mix(in_oklab,var(--color-foreground)_40%,transparent)]"
activeClassName="border-[3px] border-primary"
activeTextClassName="text-foreground font-semibold"
arrowClassName="border-2 border-[color-mix(in_oklab,var(--color-foreground)_18%,transparent)] text-foreground hover:bg-accent"
/>
)
}
/* Corner: no border; the active page is marked with an underline plus primary. */
export function CornerPagination(props: PaginationProps) {
return (
<OutlineShell
props={props}
radius="rounded-none"
idleClassName="border-b-2 border-transparent text-muted-foreground hover:border-[color-mix(in_oklab,var(--color-foreground)_25%,transparent)] hover:text-foreground"
activeClassName="border-b-2 border-primary bg-[color-mix(in_oklab,var(--color-primary)_8%,transparent)]"
activeTextClassName="text-foreground font-semibold"
arrowClassName="border-b-2 border-transparent text-foreground hover:border-[color-mix(in_oklab,var(--color-foreground)_25%,transparent)]"
/>
)
}Manual installs skip the @ai2/tokens theme, so add the token CSS from the theming guide or the tone colors will be missing.
Variations
5 takes on the same idea. Each is its own export, and every one accepts a size prop (sm, md, lg, xl) aligned to the base Button scale.
Ring
The active page is haloed by an inset primary ring.
import { RingPagination } from "@/components/ui/pagination-outline"
<RingPagination />Dashed
Dashed borders that turn primary on the active page.
import { DashedPagination } from "@/components/ui/pagination-outline"
<DashedPagination />Double
A two-layer border with an offset outer ring.
import { DoublePagination } from "@/components/ui/pagination-outline"
<DoublePagination />Thick
A heavy, assertive border weight.
import { ThickPagination } from "@/components/ui/pagination-outline"
<ThickPagination />Corner
No box, just an underline marking the active page.
import { CornerPagination } from "@/components/ui/pagination-outline"
<CornerPagination />ai2 Outline paginations: 5 styled variations on the token system
The ai2 Outline paginations are a set of 5 decorative button variations from the styled layer of the @ai2 design system, built around border-forward page navigation controls. They are free and MIT licensed, and every color comes from a semantic token, so they theme with the rest of ai2 in light and dark.
Motion runs on framer-motion: framer-motion slides the active outline between pages. The styled layer is opt-in, so the dependency only lands if you use it; the base components stay lean. Under reduced motion, the outline jumps to the active page with no animation.
What is in the ai2 Outline paginations?
5 exports in one file: Ring, Dashed, Double, Thick and Corner. Each renders a native button and takes a size prop (sm, md, lg, xl) aligned to the base Button. They are separate from the base Button on purpose: the base keeps its clean variant, tone and size axes, while the styled layer carries the effects.
You own the file. Copy the one category file and you have all 5 variations, with no runtime dependency on ai2 itself.
Why use it
- On-system by construction: Every color resolves to an ai2 semantic token, so the buttons follow your theme in light and dark with no extra work.
- Effect without the sprawl: The decorations live in a dedicated styled file, so the base Button keeps its clean, predictable API.
- Accessible and honest: Each renders a real button element, keeps a visible focus ring, and respects prefers-reduced-motion.
Features
- Token-driven color: No hardcoded hex or oklch; the look recolors with your theme tokens.
- framer-motion: framer-motion slides the active outline between pages.
- Reduced-motion aware: Under prefers-reduced-motion, the outline jumps to the active page with no animation.
- Size aligned to the base: Every variation takes sm, md, lg and xl matching the base Button height scale, so styled and base buttons line up in a row.
Production tips
- Use it for emphasis, not everywhere: Styled buttons draw the eye. Reserve them for the one action you want people to take on a screen, and use the base Button for the rest.
- Keep labels as verbs: The decoration adds weight, so a clear action label keeps the button scannable.
- Pick one variation per surface: The variations share a family; using two different ones in the same view competes for attention.
Works with the rest of ai2
The Outline paginations sit alongside the base Button and the rest of the @ai2 registry. They share the same token file, so a styled action next to a base button or a badge stays visually consistent in both modes.