pagination
neobrutalui/paginationFreeComponent
Navigate through paginated content with page indicators.
Live preview
live · rendered by the registry
Rendered by neobrutalui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://www.neobrutalui.live/r/pagination.jsonSource
1"use client"23import * as React from "react"4import { cn } from "@/lib/utils"56export type PaginationProps = React.HTMLAttributes<HTMLDivElement>78const Pagination = React.forwardRef<HTMLDivElement, PaginationProps>(9 ({ className, onKeyDown, ...props }, ref) => {10 const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {11 onKeyDown?.(event)12 if (event.defaultPrevented) return1314 if (!["ArrowRight", "ArrowLeft", "Home", "End"].includes(event.key)) return1516 const items = Array.from(17 event.currentTarget.querySelectorAll<HTMLButtonElement>("button:not(:disabled)")18 )19 if (items.length === 0) return2021 const activeElement = document.activeElement as HTMLElement | null22 const currentIndex = items.findIndex((item) => item === activeElement)2324 let nextIndex = currentIndex25 if (event.key === "Home") {26 nextIndex = 027 } else if (event.key === "End") {28 nextIndex = items.length - 129 } else if (event.key === "ArrowRight") {30 nextIndex = currentIndex < 0 ? 0 : (currentIndex + 1) % items.length31 } else if (event.key === "ArrowLeft") {32 nextIndex = currentIndex < 0 ? items.length - 1 : (currentIndex - 1 + items.length) % items.length33 }3435 items[nextIndex]?.focus()36 event.preventDefault()37 }3839 return (40 <nav41 ref={ref}42 aria-label="Pagination"43 className={cn("flex items-center justify-center border-2 border-black rounded-base", className)}44 onKeyDown={handleKeyDown}45 {...props}46 />47 )48 }49)50Pagination.displayName = "Pagination"5152export type PaginationItemProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {53 isActive?: boolean54}5556const PaginationItem = React.forwardRef<HTMLButtonElement, PaginationItemProps>(57 ({ className, isActive, ...props }, ref) => (58 <button59 ref={ref}60 className={cn(61 "inline-flex h-10 w-10 items-center justify-center text-sm font-bold transition-colors focus-brutal border-r-2 border-black last:border-r-0",62 isActive63 ? "bg-main text-black"64 : "bg-white text-black hover:bg-neutral-50",65// … truncated
What it pulls in
npm packages
Other registry items
More from neobrutalui
All 24 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| accordionaccordion | neobrutalui | Components | Free | 2 deps | |
| alertalert | neobrutalui | Components | Free | 1 dep | |
| avataravatar | neobrutalui | Components | Free | no deps | |
| badgebadge | neobrutalui | Components | Free | 1 dep | |
| buttonbutton | neobrutalui | Components | Free | 1 dep | |
| cardcard | neobrutalui | Components | Free | no deps | |
| checkboxcheckbox | neobrutalui | Components | Free | 2 deps | |
| date-pickerdate-picker | neobrutalui | Components | Free | 2 deps |
