Skip to content

[pagination] support ellipsis #1008

Description

@jer3m01

Describe The Problem To Be Solved

Fixed size pagination example from kb is best reference:
https://kobalte.dev/docs/core/components/pagination#fixed-items-example

The elements shown have to dynamically adjust for a consistent interface. Show page numbers when current page is close, show ellipsis when far.
Note: Kobalte uses siblingCount={1} instead of maxPages={7}, maybe consider using the same? (and remove maxPages)

Suggest A Solution

Add 2 props:

type PaginationOptions = {
	/** the number of pages to show at the same time around the current page */
	siblingCount?: number; // replaces maxPages
	...
	/** show an element between current page and first/last */
	showEllipsis?: boolean | ((page: number, pages: number) => boolean);
	...
	/** content for the ellipsis element, e.g. an SVG icon, default is "…" */
	ellipsisContent?: JSX.Element;
	...
}
const [paginationProps, page, setPage] =  createPagination({ pages: 10, ellipsis: true });

// works the same
<For each={paginationProps()}>{props => <button {...props} />}</For>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions