Pagination (TPagination)

VueJs Pagination component with configurable classes and infinite variants. Friendly with utility-first frameworks like TailwindCSS.

Playground:


Basic example

<t-pagination
  :total-items="totalRows"
  :per-page="perPage"
  :limit="limit"
  :disabled="disabled"
  v-model="currentPage"
/>

Props

PropertyTypeDefault valueDescription
valueNumbernullThe current page number (v-model) of the component
tagNameString'ul'The tag name that will wrapper the component
elementTagNameString'li'The tag name that will wrapper every button in the pagination
disabledBooleanfalseIf set the pagination buttons will be disabled
perPageNumber20Number of items that every page represents
limitNumber5How many buttons (including the ellipsis if shown) should be rendered
totalItemsNumber0How many items are in the list
prevLabelStringPrev button label
nextLabelStringNext button label
firstLabelString«First button label
lastLabelString»Last button label
ellipsisLabelStringEllipsis control label
hideFirstLastControlsBooleanfalseIf set will hide the first and last controls
hidePrevNextControlsBooleanfalseIf set will hide the prev and next controls
hideEllipsisBooleanfalseIf set will hide ellipsis control
fixedClassesObjectundefinedThe default CSS Fixed classes shared for all variants
classesObject{...} (see below)The default CSS classes
variantsObjectundefinedThe different variants of classes the component have
variant[String, Object]undefinedThe variant that should be used

Classes and variants format

This component expects an object with classes named after every child element.

The properties in that object are the following:

PropertyDescription
wrapperThe tag name that wraps the component
elementA single page element
disabledElementA single page element when component is disabled
ellipsisElementThe element with the ellipsis
buttonThe button
activeButtonThe button when is active
disabledButtonThe butotn when is disabled
ellipsisThe ellipsis button

Default classes

{
  wrapper: 'table border-collapse text-center bg-white mx-auto mt-2',
  element: 'w-8 h-8 border table-cell',
  disabledElement: 'w-8 h-8 border table-cell',
  ellipsisElement: 'w-8 h-8 border hidden md:table-cell',
  activeButton: 'bg-gray-300 w-full h-full',
  disabledButton: 'opacity-25 w-full h-full cursor-not-allowed',
  button: 'hover:bg-gray-200 w-full h-full',
  ellipsis: '',
}

Events

EventArgumentsDescription
inputNumber (The current selected page)Emitted when the page change
changeNumber (The current selected page)Emitted when the page change