UsePaginationDemo
guarahooks/use-pagination-demoFreeExample
use-pagination's hook in action.
Live preview
live · rendered by the registry
Rendered by guarahooks on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://guarahooks.com/r/use-pagination-demo.jsonSource
1'use client';23import React from 'react';45import { Button } from '@/components/ui/button';6import {7 Card,8 CardContent,9 CardDescription,10 CardFooter,11 CardHeader,12 CardTitle,13} from '@/components/ui/card';1415import { usePagination } from '@/hooks/guarahooks/use-pagination';1617export default function UsePaginationDemo() {18 const totalItems = 100;19 const {20 page,21 pageSize,22 totalPages,23 setPage,24 nextPage,25 prevPage,26 setPageSize,27 } = usePagination(totalItems, { initialPage: 1, initialPageSize: 10 });2829 return (30 <Card className="relative max-w-sm w-full">31 <CardHeader>32 <CardTitle>usePagination</CardTitle>33 <CardDescription>34 Example of pagination using the <code>usePagination</code> hook.35 </CardDescription>36 </CardHeader>3738 <CardContent>39 <p>40 Page: <strong>{page}</strong> of <strong>{totalPages}</strong>41 </p>42 <p>43 Items per page: <strong>{pageSize}</strong>44 </p>45 </CardContent>4647 <CardFooter className="flex flex-wrap gap-2">48 <Button onClick={() => setPageSize(5)}>5 / page</Button>49 <Button onClick={() => setPageSize(10)}>10 / page</Button>50 <Button onClick={() => setPageSize(20)}>20 / page</Button>51 <Button onClick={prevPage} disabled={page <= 1}>52 Previous53 </Button>54 <Button onClick={nextPage} disabled={page >= totalPages}>55 Next56 </Button>57 </CardFooter>58 </Card>59 );60}
What it pulls in
Other registry items
Files it writes
More from guarahooks
All 100 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| UseAbortControllerDemouse-abort-controller-demo | guarahooks | Examples | Free | no deps | |
| UseArrayStateDemouse-array-state-demo | guarahooks | Examples | Free | no deps | |
| UseAxiosDemouse-axios-demo | guarahooks | Examples | Free | no deps | |
| UseBatteryStatusDemouse-battery-status-demo | guarahooks | Examples | Free | no deps | |
| UseBetterAuthDemouse-better-auth-demo | guarahooks | Examples | Free | no deps | |
| UseClickOutsideDemouse-click-outside-demo | guarahooks | Examples | Free | no deps | |
| UseConfirmDemouse-confirm-demo | guarahooks | Examples | Free | no deps | |
| UseCookieDemouse-cookie-demo | guarahooks | Examples | Free | no deps |
