Pagination
Basic usage
<script>
let current
</script>
<CPagination pages={6} bind:current />
<script>
let current
</script>
<CPagination pages={6} bind:current />
Shapes
<script>
let current
</script>
<div class="c-column c-gutter-md">
<CPagination pages={6} bind:current shape="square" />
<CPagination pages={6} bind:current shape="rounded" />
<CPagination pages={6} bind:current shape="circle" />
</div>
<script>
let current
</script>
<div class="c-column c-gutter-md">
<CPagination pages={6} bind:current shape="square" />
<CPagination pages={6} bind:current shape="rounded" />
<CPagination pages={6} bind:current shape="circle" />
</div>
Sizes
<script>
let current
</script>
<div class="c-column c-gutter-md">
<CPagination pages={6} bind:current size="xs" />
<CPagination pages={6} bind:current size="sm" shape="rounded" />
<CPagination pages={6} bind:current shape="circle" />
<CPagination pages={6} bind:current size="lg" shape="rounded" />
<CPagination pages={6} bind:current size="xl" />
</div>
<script>
let current
</script>
<div class="c-column c-gutter-md">
<CPagination pages={6} bind:current size="xs" />
<CPagination pages={6} bind:current size="sm" shape="rounded" />
<CPagination pages={6} bind:current shape="circle" />
<CPagination pages={6} bind:current size="lg" shape="rounded" />
<CPagination pages={6} bind:current size="xl" />
</div>
Gutter sizes
<script>
let current
</script>
<div class="c-column c-gutter-md">
<CPagination pages={6} bind:current gutterSize="xs" />
<CPagination pages={6} bind:current gutterSize="sm" />
<CPagination pages={6} bind:current />
<CPagination pages={6} bind:current gutterSize="lg" />
<CPagination pages={6} bind:current gutterSize="xl" />
</div>
<script>
let current
</script>
<div class="c-column c-gutter-md">
<CPagination pages={6} bind:current gutterSize="xs" />
<CPagination pages={6} bind:current gutterSize="sm" />
<CPagination pages={6} bind:current />
<CPagination pages={6} bind:current gutterSize="lg" />
<CPagination pages={6} bind:current gutterSize="xl" />
</div>
Themes
<script>
let current
</script>
<div class="c-column c-gutter-md">
<CPagination pages={6} bind:current theme="primary" shape="circle" />
<CPagination pages={6} bind:current theme="secondary" shape="circle" />
<CPagination pages={6} bind:current theme="warning" shape="circle" />
<CPagination pages={6} bind:current theme="negative" shape="circle" />
</div>
<script>
let current
</script>
<div class="c-column c-gutter-md">
<CPagination pages={6} bind:current theme="primary" shape="circle" />
<CPagination pages={6} bind:current theme="secondary" shape="circle" />
<CPagination pages={6} bind:current theme="warning" shape="circle" />
<CPagination pages={6} bind:current theme="negative" shape="circle" />
</div>
No to first/last button
<script>
let current
</script>
<CPagination pages={6} bind:current showBoundaryButton={false} />
<script>
let current
</script>
<CPagination pages={6} bind:current showBoundaryButton={false} />
No prev/next button
<script>
let current
</script>
<CPagination pages={6} bind:current showPrevNextButton={false} />
<script>
let current
</script>
<CPagination pages={6} bind:current showPrevNextButton={false} />
Max display pages
<script>
let current = 4
</script>
<CPagination pages={10} maxDisplayPages={3} bind:current />
<script>
let current = 4
</script>
<CPagination pages={10} maxDisplayPages={3} bind:current />
Customize buttons with slots
<script>
let current = 4
</script>
<CPagination pages={10} maxDisplayPages={3} bind:current>
<button slot="to-first" let:set let:disabled on:click={set} {disabled}>
To first
</button>
<CButton
slot="to-prev"
let:set
let:disabled
on:click={set}
{disabled}
flat
theme="negative"
>
<div class="i-ph-arrow-arc-left-fill"></div>
</CButton>
<CButton slot="left-ellipsis" let:set flat theme="warning" on:click={set}>
<div class="i-ion-ellipsis-horizontal-circle"></div>
</CButton>
<CButton slot="right-ellipsis" let:set flat theme="warning" on:click={set}>
<div class="i-octicon-ellipsis-16"></div>
</CButton>
<CButton
slot="to-next"
let:set
let:disabled
on:click={set}
{disabled}
flat
theme="secondary"
>
<div class="i-ph-arrow-arc-right-fill"></div>
</CButton>
<button slot="to-last" let:set let:disabled on:click={set} {disabled}>
To last
</button>
</CPagination>
<script>
let current = 4
</script>
<CPagination pages={10} maxDisplayPages={3} bind:current>
<button slot="to-first" let:set let:disabled on:click={set} {disabled}>
To first
</button>
<CButton
slot="to-prev"
let:set
let:disabled
on:click={set}
{disabled}
flat
theme="negative"
>
<div class="i-ph-arrow-arc-left-fill"></div>
</CButton>
<CButton slot="left-ellipsis" let:set flat theme="warning" on:click={set}>
<div class="i-ion-ellipsis-horizontal-circle"></div>
</CButton>
<CButton slot="right-ellipsis" let:set flat theme="warning" on:click={set}>
<div class="i-octicon-ellipsis-16"></div>
</CButton>
<CButton
slot="to-next"
let:set
let:disabled
on:click={set}
{disabled}
flat
theme="secondary"
>
<div class="i-ph-arrow-arc-right-fill"></div>
</CButton>
<button slot="to-last" let:set let:disabled on:click={set} {disabled}>
To last
</button>
</CPagination>
CPagination Props
- pagesdefault:
number
0
The total page count
- shapedefault:
'circle' | 'square' | 'rounded'
square
- currentdefault:
number
1
Current page. It is recommended to use
bind:current
- maxDisplayPagesdefault:
number
5
The max page count to display. Will display ... when the pages is larger than this
- sizedefault:
any
undefined
The size of all buttons
- gutterSizedefault:
string
md
The gutter size between each button
- themedefault:
any
undefined
The theme of all buttons
- showBoundaryButtondefault:
boolean
true
Determine whether to show the to first/last button or not.
- showPrevNextButtondefault:
boolean
true
Determine whether to show the to prev/next button or not.
CPagination Events
CPagination Slots
- to-first
Customize the "to first" button
Bindings:
- set
function
Set first page
- disabled
function
Determine whether the button should be disabled or not
- set
- to-prev
Customize the "to prev" button
Bindings:
- set
function
Do set previous page
- disabled
boolean
Determine whether the button should be disabled or not
- set
- left-ellipsis
Customize the left ellipsis button
Bindings:
- set
function
Set left ellipsis page
- set
- page-button
Customize the page button
Bindings:
- p
number
The page number
- active
boolean
Determine whether the button is active or not
- p
- right-ellipsis
Customize the right ellipsis button
Bindings:
- set
function
Set right ellipsis page
- set
- to-next
Customize the "to next" button
Bindings:
- set
function
Set next page
- disabled
boolean
Determine whether the button should be disabled or not
- set
- to-last
Customize the "to last" button
Bindings:
- set
function
Set last page
- disabled
boolean
Determine whether the button should be disabled or not
- set