Files
website/src/lib/components/ui/Pagination.svelte
T

39 lines
918 B
Svelte

<script lang="ts">
let { currentPage = $bindable(), totalPages }: { currentPage: number; totalPages: number } = $props();
</script>
{#if totalPages > 1}
<nav class="pagination" aria-label="Pagination">
<button disabled={currentPage === 1} onclick={() => currentPage--}>&lt; prev</button>
<span class="muted">page {currentPage} of {totalPages}</span>
<button disabled={currentPage === totalPages} onclick={() => currentPage++}>next &gt;</button>
</nav>
{/if}
<style>
.pagination {
display: flex;
justify-content: center;
align-items: center;
gap: 1rem;
margin-top: 1.25rem;
}
button {
padding: 0.1rem 0.6rem;
background: none;
border: 1px solid color-mix(in srgb, var(--foreground) 25%, transparent);
color: var(--muted);
}
button:hover:not(:disabled) {
border-color: var(--accent);
color: var(--foreground);
}
button:disabled {
opacity: 0.4;
cursor: default;
}
</style>