npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue3-basic-pagination

v1.0.0

Published

Vue3 pagination component.

Downloads

36

Readme

vue3-plain-pagination

NPM

NPM version tests codecov License

vue javascript vitejs rollup

Simple pagination component for Vue3 / Nuxt3. Can be easily customized via css and/or slots.

Installation

NPM

Install the npm package.

$ npm install vue3-basic-pagination --save

Register as plugin So there is no need to import it every time.

// main.js or main.ts
import { createApp } from 'vue'
import App from './App.vue'
import PaginationPlugin from 'vue3-basic-pagination' // import component
import 'vue3-basic-pagination/styles' // register default styles

const app = createApp(App)
app.use(PaginationPlugin) // register plugin
app.mount('#app')

As component

// CustomComponent.vue
import PaginationPlugin from 'vue3-basic-pagination'

Usage

In Vue Template

Basic Usage

<basic-pagination :page-count="20" />

Or

<BasicPagination :pageCount="20" />

Props

| Name | Type | Default | Description | |-|-|-|-| | page-count (required) | Number | | Total pages. | | page-range | Number | 5 | Range of pages which displayed. | | margin-pages | Number | 1 | The number of displayed pages for margins. | | show-first-last-buttons | Boolean | true | Whether to show or hide buttons to navigate to first and last pages. | | show-prev-next-buttons | Boolean | true | Whether to show or hide buttons to navigate to previous and next pages. | | container-class | string | vue3-basic-pagination | CSS class name for the layout. | | page-class | string | page-item | CSS class name for tag li of each page element. | | page-link-class | string | page-link | CSS class name for tag span of each page element. | | disabled-class | string | disabled-item | CSS class name for tag li of disabled element(s). | | first-item-class | string | first-item | CSS class name for tag li of first element. | | first-item-link-class | string | first-link | CSS class name for tag span of first element. | | last-item-class | string | last-item | CSS class name for tag li of last element. | | last-item-link-class | string | last-link | CSS class name for tag span of last element. | | prev-item-class | string | prev-item | CSS class name for tag li of previous element. | | prev-item-link-class | string | prev-link | CSS class name for tag span of previous element. | | next-item-class | string | next-item | CSS class name for tag li of next element. | | next-item-link-class | string | next-link | CSS class name for tag span of next element. | | break-view-class | string | break-item | CSS class name for tag li of break element. | | break-view-link-class | string | break-link | CSS class name for tag span of break element. | | active-class | string | active-item | CSS class name for tag li of active element. |

Using props

<template>
  <BasicPagination
    :page-count="20"
    :page-range="5"
    :margin-pages="3"
    :container-class="'custom-container-class'"
  >
  </BasicPagination>
</template>

<script setup lang="ts">
import { useRoute, useRouter } from 'vue-router'
// import PaginationPlugin from 'vue3-basic-pagination' // uncomment if not registered as plugin

const route = useRoute()
const router = useRouter()

const customFunc = (pageIndex: number): void => {
  const query = { ...route.query, ...{ page: pageIndex } }
  router.push({ name: '', query: query })
}
</script>

Events

| Name | Return Type | Description | |-|-|-| | page-selected | Number | Selected page number. |

Using events

<template>
  <BasicPagination
    :page-count="20"
    @pageSelected="customFunc"
  >
  </BasicPagination>
</template>

<script setup lang="ts">
import { useRoute, useRouter } from 'vue-router'
// import PaginationPlugin from 'vue3-basic-pagination' // uncomment if not registered as plugin

const route = useRoute()
const router = useRouter()

const customFunc = (pageIndex: number): void => {
  const query = { ...route.query, ...{ page: pageIndex } }
  router.push({ name: '', query: query })
}
</script>

Slots

| Name | Description | |-|-| | firstButtonContent | Content of first page item. | | lastButtonContent | Content of last page item. | | prevButtonContent | Content of prev page item. | | nextButtonContent | Content of next page item. | | pageContent | Content of page item. | | currentPageContent | Content of current page item. | | breakViewContent | Content of break item. |

Using slots

<BasicPagination
  :page-count="7"
>
  <template v-slot:firstButtonContent>
    <router-link :to="{ path: '' }">
      F I R S T
    </router-link>
  </template>
  <template v-slot:prevButtonContent="slotProps">
    <router-link :to="{ name: '', query: { page: slotProps.pageNumber } }">
      P R E V
    </router-link>
  </template>
  <template v-slot:breakViewContent>
    ---
  </template>
  <template v-slot:pageContent="slotProps">
    <router-link :to="{ name: '', query: { page: slotProps.pageNumber } }">
      p {{ slotProps.pageNumber }}
    </router-link>
  </template>
  <template v-slot:currentPageContent="slotProps">
    &gt;&gt; {{ slotProps.pageNumber }} &lt;&lt;
  </template>
  <template v-slot:nextButtonContent="slotProps">
    <router-link :to="{ name: '', query: { page: slotProps.pageNumber } }">
      N E X T
    </router-link>
  </template>
  <template v-slot:lastButtonContent="slotProps">
    <router-link :to="{ name: '', query: { page: slotProps.pageNumber } }">
      L A S T
    </router-link>
  </template>
</BasicPagination>