Pagination
docs/paginationFreeComponent
pagination component for SolidJS
Live preview
live · rendered by the registry
Rendered by docs on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://solidcn.dev/r/pagination.jsonSource
1import { ChevronLeft, ChevronRight, MoreHorizontal } from "lucide-solid";2import type { Component, JSX } from "solid-js";3import { splitProps } from "solid-js";4import { cn } from "~/lib/utils";5import { buttonVariants } from "./button";67const Pagination: Component<JSX.HTMLAttributes<HTMLElement>> = (props) => {8 const [local, rest] = splitProps(props, ["class"]);9 return (10 <nav11 aria-label="pagination"12 class={cn("mx-auto flex w-full justify-center", local.class)}13 {...rest}14 />15 );16};1718const PaginationContent: Component<JSX.HTMLAttributes<HTMLUListElement>> = (props) => {19 const [local, rest] = splitProps(props, ["class"]);20 return <ul class={cn("flex flex-row items-center gap-1", local.class)} {...rest} />;21};2223const PaginationItem: Component<JSX.HTMLAttributes<HTMLLIElement>> = (props) => {24 const [local, rest] = splitProps(props, ["class"]);25 return <li class={cn("", local.class)} {...rest} />;26};2728type PaginationLinkProps = JSX.AnchorHTMLAttributes<HTMLAnchorElement> & {29 isActive?: boolean;30 size?: "default" | "sm" | "lg" | "icon";31};3233const PaginationLink: Component<PaginationLinkProps> = (props) => {34 const [local, rest] = splitProps(props, ["class", "isActive", "size"]);35 return (36 <a37 aria-current={local.isActive ? "page" : undefined}38 class={cn(39 buttonVariants({40 variant: local.isActive ? "outline" : "ghost",41 size: local.size ?? "icon",42 }),43 local.class,44 )}45 {...rest}46 />47 );48};4950const PaginationPrevious: Component<JSX.AnchorHTMLAttributes<HTMLAnchorElement>> = (props) => {51 const [local, rest] = splitProps(props, ["class"]);52 return (53 <PaginationLink54 aria-label="Go to previous page"55 size="default"56 class={cn("gap-1 pl-2.5", local.class)}57 {...rest}58 >59 <ChevronLeft class="h-4 w-4" />60 <span>Previous</span>61 </PaginationLink>62 );63};6465const PaginationNext: Component<JSX.AnchorHTMLAttributes<HTMLAnchorElement>> = (props) => {66 const [local, rest] = splitProps(props, ["class"]);67 return (68 <PaginationLink69 aria-label="Go to next page"70 size="default"71 class={cn("gap-1 pr-2.5", local.class)}72 {...rest}73 >74 <span>Next</span>75 <ChevronRight class="h-4 w-4" />76 </PaginationLink>77 );78};7980const PaginationEllipsis: Component<JSX.HTMLAttributes<HTMLSpanElement>> = (props) => {81 const [local, rest] = splitProps(props, ["class"]);82 return (83 <span84// … truncated
More from docs
All 44 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | docs | Components | Free | no deps | |
| Alert Dialogalert-dialog | docs | Components | Free | no deps | |
| Avataravatar | docs | Components | Free | no deps | |
| Badgebadge | docs | Components | Free | no deps | |
| Breadcrumbbreadcrumb | docs | Components | Free | no deps | |
| Buttonbutton | docs | Components | Free | no deps | |
| Calendarcalendar | docs | Components | Free | no deps | |
| Cardcard | docs | Components | Free | no deps |
