1.1.0 • Published 3 years ago

@pmwcs/pagination v1.1.0

Weekly downloads
5
License
MIT
Repository
github
Last release
3 years ago

Pagination (PMWCS Addon)

The Pagination component enables the user to select a specific page from a range of pages.

  • Module @pmwcs/pagination
  • Import styles:
    • Using CSS Loader
      • import '@pmwcs/pagination/styles';
    • Or include stylesheets
      • '@pmwcs/icon-button/styles'
      • '@pmwcs/pagination/pagination.css'

Uncontrolled

<Pagination onChange={(evt, page) => {}} />
<Pagination count={3} onChange={(evt, page) => {}} defaultPage={1} />
<Pagination count={5} onChange={(evt, page) => {}} defaultPage={3} showFirstButton showLastButton />

Controlled

function MyPagination ({ count }) {
  const [page, setPage] = useState(1)

  return (
    <Pagination
      page={page}
      count={count}
      onChange={(evt, page) => setPage(page)}
    />
  )
}

Variants

<Pagination primary count={10}  />
<Pagination secondary count={10} />
<Pagination disabled count={10} />
<Pagination rounded count={3} />

Pagination

Enables the user to select a specific page from a range of pages.

Props

NameTypeDescription
boundaryCountnumberNumber of always visible pages at the beginning and end. Default is 1.
countnumberThe total number of pages. Default is 1.
defaultPagenumberThe page selected by default when the component is uncontrolled. Default is 1.
pagenumberThe page selected. (controlled mode)
disabledbooleanIf true, the pagination component will be disabled.
hideNextButtonbooleanIf true, hide the next-page button.
hidePrevButtonbooleanIf true, hide the previous-page button.
onChange(event: Event, page: number) => voidCallback fired when the page is changed. event The event source of the callback. page The page selected.
showFirstButtonbooleanIf true, show the first-page button.
showLastButtonbooleanIf true, show the last-page button.
siblingCountnumberNumber of always visible pages before and after the current page. Default is 1.
classNamestringadditional className of ul element
getItemAriaLabel(type, page, selected) => stringCustom label generator for aria labels.
renderItem(item) => <PaginationItem {...item} />Custom render item. Defaults to PaginationItem.
roundedbooleanThe shape of the pagination items, rounded edges instead of circle.
size'small' \| 'medium' \| 'large'The size of the pagination component.
primarybooleanPrimary theme.
secondarybooleanSecondary theme.

PaginationItem

Pagination element to select a specific page.

NameTypeDescription
classNamestringAdditional className
disabledbooleanDisabled component if true. @default false
pagenumberpage number on click
selectedbooleanitem is selected
roundedbooleanitem has rounded corners. If false then item is displayed with circle.
size'small' \| 'medium' \| 'large'different sizes of component. @default 'medium'
type'page' \| 'start-ellipsis' \| 'end-ellipsis' \| 'previous' \| 'next' \| 'first' \| 'last'type of item