In this tutorial, we will create paginations in next js 13 with shadcn ui. First you need to setup next js 13 with shadcn ui project.
how to use shadcn ui in next js 13
Before use pagination in next js 13 with shadcn ui you need to install npx shadcn-ui add button.
npx shadcn-ui add button
or
npx shadcn-ui@latest add
Next 13 with Shadcn UI Pagination Example
1. Create next js 13 with shadcn ui simple paginations using shadcn-ui Button component.
import { Button } from "@/components/ui/button"
export default function PaginationDemo() {
return (
<>
<div>
<Button variant="outline" size="sm">
1
</Button>
<Button variant="outline" size="sm">
2
</Button>
<Button variant="outline" size="sm">
3
</Button>
</div>
</>
)
}
2. next js 13 with shadcn ui full rounded paginations.
import { Button } from "@/components/ui/button"
export default function PaginationDemo() {
return (
<>
<div>
<Button variant="outline" className="rounded-full" size="sm">
1
</Button>
<Button variant="outline" className="rounded-full" size="sm">
2
</Button>
<Button variant="outline" className="rounded-full" size="sm">
3
</Button>
</div>
</>
)
}
3. next js 13 with shadcn ui next page and previous paginations.
import { Button } from "@/components/ui/button"
export default function PaginationDemo() {
return (
<>
<div className="space-x-2">
<Button variant="outline" size="sm">
Previous
</Button>
<Button variant="outline" size="sm">
Next
</Button>
</div>
</>
)
}
4. next js 13 with shadcn ui paginations using map functions.
import { Button } from "@/components/ui/button"
export default function PaginationDemo() {
const buttonData = [1, 2, 3, 4, 5]
return (
<>
<div>
{buttonData.map((number) => (
<Button
key={number}
variant="outline"
size="sm"
className="rounded-full"
>
{number}
</Button>
))}
</div>
</>
)
}
5. next js 13 with shadcn ui paginations using Button component and nextjs Link.
import Link from "next/link"
import { buttonVariants } from "@/components/ui/button"
export default function PaginationDemo() {
const buttonData = [1, 2, 3, 4, 5]
return (
<>
<div>
{buttonData.map((number) => (
<Link
key={number}
className={buttonVariants({ variant: "outline" })}
href={""}
>
{number}
</Link>
))}
</div>
</>
)
}
Related Posts
create a accordion in nextjs 13 with shadcn ui
create sidebar in next 13 with shadcn ui
create footer section in next 13 with shadcn ui
create file upload in nextjs 13 with shadcn ui
next 13 with shadcn ui input field example
next 13 with shadcn ui cards example
next 13 with shadcn ui search bar example
next 13 with shadcn ui login page example
next 13 with shadcn ui sign up form example
next 13 with shadcn ui radio group example
next 13 with shadcn ui buttons example
next 13 with shadcn ui table example
next 13 with shadcn ui checkbox example
next 13 with shadcn ui dropdown menu example
how to use skeleton loading next 13 with shadcn ui
how to use data table next 13 with shadcn ui
how to use modal dialog next 13 with shadcn ui
how to use tabs next 13 with shadcn ui
how to use toggle switch next 13 with shadcn ui