pagination
9ui/paginationFreeComponent
9ui publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by 9ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://9ui.dev/r/pagination.jsonSource
1import * as React from "react"2import { mergeProps } from "@base-ui/react"3import { useRender } from "@base-ui/react/use-render"4import {5 ChevronLeftIcon,6 ChevronRightIcon,7 MoreHorizontalIcon,8} from "lucide-react"910import { Button, buttonVariants } from "@/components/ui/button"1112import { cn } from "@/lib/utils"1314function Pagination({ className, ...props }: React.ComponentProps<"nav">) {15 return (16 <nav17 role="navigation"18 aria-label="pagination"19 data-slot="pagination"20 className={cn("mx-auto flex w-full justify-center", className)}21 {...props}22 />23 )24}2526function PaginationContent({27 className,28 ...props29}: React.ComponentProps<"ul">) {30 return (31 <ul32 data-slot="pagination-content"33 className={cn("flex flex-row items-center gap-1", className)}34 {...props}35 />36 )37}3839function PaginationItem({ ...props }: React.ComponentProps<"li">) {40 return <li data-slot="pagination-item" {...props} />41}4243type PaginationLinkProps = {44 isActive?: boolean45} & Pick<React.ComponentProps<typeof Button>, "size"> &46 useRender.ComponentProps<"a">4748function PaginationLink({49 className,50 isActive,51 size = "icon",52 render = <a />,53 ...props54}: PaginationLinkProps) {55 const defaultProps = {56 "aria-current": isActive ? "page" : undefined,57 "data-slot": "pagination-link",58 "data-active": isActive,59 className: cn(60 buttonVariants({61 variant: isActive ? "outline" : "ghost",62 size,63 }),64 className65 ),66 } as const6768 const element = useRender({69 render,70 props: mergeProps<"a">(defaultProps, props),71 })7273 return element74}7576function PaginationPrevious({77 className,78 ...props79}: React.ComponentProps<typeof PaginationLink>) {80 return (81 <PaginationLink82 aria-label="Go to previous page"83 size="default"84 className={cn("gap-1 px-2.5 sm:pl-2.5", className)}85 {...props}86 >87 <ChevronLeftIcon />88 <span className="hidden sm:block">Previous</span>89 </PaginationLink>90 )91}9293function PaginationNext({94 className,95 ...props96}: React.ComponentProps<typeof PaginationLink>) {97 return (98 <PaginationLink99 aria-label="Go to next page"100 size="default"101 className={cn("gap-1 px-2.5 sm:pr-2.5", className)}102 {...props}103 >104 <span className="hidden sm:block">Next</span>105 <ChevronRightIcon />106 </PaginationLink>107 )108}109110function PaginationEllipsis({111 className,112 ...props113}: React.ComponentProps<"span">) {114 return (115 <span116 aria-hidden117 data-slot="pagination-ellipsis"118 className={cn("flex size-9 items-center justify-center", className)}119// … truncated
Files it writes
More from 9ui
All 56 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| accordionaccordion | 9ui | Components | Free | no deps | |
| alertalert | 9ui | Components | Free | no deps | |
| alert-dialogalert-dialog | 9ui | Components | Free | no deps | |
| aspect-ratioaspect-ratio | 9ui | Components | Free | no deps | |
| autocompleteautocomplete | 9ui | Components | Free | no deps | |
| avataravatar | 9ui | Components | Free | no deps | |
| badgebadge | 9ui | Components | Free | no deps | |
| breadcrumbsbreadcrumbs | 9ui | Components | Free | no deps |
