Pagination
adn-ui/paginationFreeComponent
Pagination with page navigation links, previous/next controls, and ellipsis.
Live preview
live · rendered by the registry
Rendered by adn-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://ui.awaiden.com/r/pagination.jsonSource
1"use client";23import "./pagination.css";4import type React from "react";5import { cn } from "tailwind-variants";67import { PaginationContext, usePaginationContext } from "./pagination.context";8import { paginationVariants, type PaginationVariants } from "./pagination.variants";910export type PaginationProps = PaginationVariants & React.ComponentProps<"nav">;1112export const PaginationRoot = ({ children, className, size, ...props }: PaginationProps) => {13 const slots = paginationVariants({ size });1415 return (16 <PaginationContext.Provider value={{ slots }}>17 <nav18 aria-label="pagination"19 className={cn(slots.root(), className)}20 {...props}21 >22 {children}23 </nav>24 </PaginationContext.Provider>25 );26};2728export type PaginationContentProps = React.ComponentProps<"ul">;2930export const PaginationContent = ({ className, ...props }: PaginationContentProps) => {31 const { slots } = usePaginationContext();32 return <ul className={cn(slots.content(), className)} {...props} />;33};3435export type PaginationItemProps = React.ComponentProps<"li">;3637export const PaginationItem = ({ className, ...props }: PaginationItemProps) => {38 const { slots } = usePaginationContext();39 return <li className={cn(slots.item(), className)} {...props} />;40};4142export type PaginationLinkProps = {43 isActive?: boolean;44} & React.ComponentProps<"a">;4546export const PaginationLink = ({47 className,48 isActive,49 "aria-current": ariaCurrent,50 ...props51}: PaginationLinkProps) => {52 const { slots } = usePaginationContext();53 return (54 <a55 aria-current={isActive ? (ariaCurrent ?? "page") : undefined}56 className={cn(57 slots.link(),58 isActive && "pagination__link--active",59 className60 )}61 {...props}62 />63 );64};6566export type PaginationPreviousProps = React.ComponentProps<typeof PaginationLink>;6768export const PaginationPrevious = ({69 className,70 children,71 ...props72}: PaginationPreviousProps) => (73 <PaginationLink74 aria-label="Go to previous page"75 className={cn("gap-1 pl-2.5", className)}76 {...props}77 >78 {children ?? (79 <>80 <svg className="h-4 w-4 stroke-current" fill="none" strokeWidth="2" viewBox="0 0 24 24">81 <path d="M15 18l-6-6 6-6" />82 </svg>83 <span>Previous</span>84 </>85 )}86 </PaginationLink>87);8889export type PaginationNextProps = React.ComponentProps<typeof PaginationLink>;9091export const PaginationNext = ({92 className,93 children,94// … truncated
What it pulls in
npm packages
Files it writes
More from adn-ui
All 46 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | adn-ui | Components | Free | 2 deps · 5 files | |
| Alert Dialogalert-dialog | adn-ui | Components | Free | 2 deps · 5 files | |
| Aspect Ratioaspect-ratio | adn-ui | Components | Free | 1 dep · 5 files | |
| Autocompleteautocomplete | adn-ui | Components | Free | 2 deps · 5 files | |
| Avataravatar | adn-ui | Components | Free | 2 deps · 5 files | |
| Badgebadge | adn-ui | Components | Free | 1 dep · 5 files | |
| Breadcrumbbreadcrumb | adn-ui | Components | Free | 1 dep · 5 files | |
| Buttonbutton | adn-ui | Components | Free | 1 dep · 4 files |
