docs(pagination): improve docs

This commit is contained in:
Eric Liu 2025-05-03 10:28:46 -07:00
commit 639626c1b3

View file

@ -7,47 +7,52 @@ components: ["Pagination", "PaginationSkeleton"]
import Preview from "../../components/Preview.svelte"; import Preview from "../../components/Preview.svelte";
</script> </script>
`Pagination` provides navigation controls for large data sets. It displays the current page, total items, and allows users to change page size and navigate between pages.
## Default ## Default
<Pagination totalItems={102} pageSizes="{[10, 15, 20]}" /> Create a basic pagination component with default page size options.
<Pagination totalItems={102} pageSizes={[10, 15, 20]} />
## Current page ## Current page
Set the current page using the `page` prop.
<Pagination totalItems={102} page={4} /> <Pagination totalItems={102} page={4} />
## Custom page sizes ## Custom page sizes
<Pagination totalItems={102} pageSizes="{[16, 36, 99]}" pageSize="{36}" /> Specify custom page sizes and set a default page size.
<Pagination totalItems={102} pageSizes={[16, 36, 99]} pageSize={36} />
## Unknown pages ## Unknown pages
If the total number of pages is unknown, set `pagesUnknown` to `true`. Set `pagesUnknown` to `true` when the total number of pages is unknown. This renders the item range text without factoring in the total number of pages.
This will render the item range text without factoring in the total number of pages.
<Pagination pagesUnknown /> <Pagination pagesUnknown />
## Page window ## Page window
The number of native select items rendered is derived from the value of `totalItems`. The number of native select items rendered is derived from `totalItems`. For large datasets, this can impact performance. Use `pageWindow` to control the number of rendered items.
If `totalItems` is a very large number, this can impact rendering performance since
thousands of elements may be rendered. By default, the window of rendered items is
capped at 1,000. For example, if `totalItems=100_000` and the `pageSize=10`,
1,000 select options are rendered.
Use the `pageWindow` prop to increase this value.
<Pagination totalItems={100_000} pageSizes={[10, 15, 20]} /> <Pagination totalItems={100_000} pageSizes={[10, 15, 20]} />
## Hidden page input ## Hidden page input
Disable the page input by setting `pageInputDisabled` to `true`.
<Pagination totalItems={102} pageInputDisabled /> <Pagination totalItems={102} pageInputDisabled />
## Hidden page size ## Hidden page size
Disable the page size selector by setting `pageSizeInputDisabled` to `true`.
<Pagination totalItems={102} pageSizeInputDisabled /> <Pagination totalItems={102} pageSizeInputDisabled />
## Skeleton ## Skeleton
Use `PaginationSkeleton` to show a loading state.
<PaginationSkeleton /> <PaginationSkeleton />