nb-page-scroll-bar

This is a page scroll progress bar component for Vue.js 3+. It automatically displays a progress bar at the top or bottom of the page that indicates how far the user has scrolled through the page content.

Loading component...

Installation

Yarn
yarn add @vlalg-nimbus/nb-loaders
NPM
npm install @vlalg-nimbus/nb-loaders

Usage

Vue 3
import { createApp } from 'vue'
import App from './App.vue'

import NbLoadersComponents from '@vlalg-nimbus/nb-loaders'
import "@vlalg-nimbus/nb-loaders/dist/style.css";

const app = createApp(App)
app.use(NbLoadersComponents)
app.mount('#app')
Nuxt 3
import NbLoadersComponents from '@vlalg-nimbus/nb-loaders'
import "@vlalg-nimbus/nb-loaders/dist/style.css";

export default defineNuxtPlugin(context => {
  context.vueApp.use(NbLoadersComponents)
})

To use, simply call the component, in this case it will be NbPageScrollBar or nb-page-scroll-bar.

Important: The NbPageScrollBar component uses position: fixed and automatically detects page scroll. It only appears when the page has been scrolled (scroll position > 0). The component automatically calculates the scroll progress and updates the bar width accordingly.

Mode 1
<template>
  <NbPageScrollBar nb-id="page-scroll-bar-1" />
</template>
Mode 2
<template>
  <nb-page-scroll-bar nb-id="page-scroll-bar-1" />
</template>
Mode 3
<template>
  <nb-page-scroll-bar nb-id="page-scroll-bar-1"></nb-page-scroll-bar>
</template>

Preview & Playground

Select the component you want to edit/test

Loading Sandbox...

Props

Items with an (*) mean they are required

nameValue typeDefaultDescription
nbId (*)StringSets the id attribute to differentiate from other components
ariaLabelString'Alternate Text Button'Defines the aria-label attribute for screen readers
ariaAttrsObject{}Allows passing custom aria attributes as an object. Keys will automatically receive the aria- prefix
backgroundColorString'transparent'Defines the background color of the container. Accepts Color name, Hex, and RGB
progressColorString'linear-gradient(to right,rgb(118, 56, 250),rgb(255, 214, 0),rgb(255, 122, 0),rgb(255, 1, 105),rgb(211, 0, 197),rgb(118, 56, 250),rgb(255, 214, 0))'Defines the progress bar color. Accepts Color name, Hex, RGB, and Gradient
heightNumber2Defines the height of the scroll bar in pixels
borderRadiusNumber0.5Defines the border radius in rem units
positionString'top'Defines the position of the scroll bar. Accepts top and bottom
topNumber0Defines the top offset in pixels (when position is 'top')
bottomNumber0Defines the bottom offset in pixels (when position is 'bottom')
leftNumber-1Defines the left offset in pixels (-1 means full width)
rightNumber-1Defines the right offset in pixels (-1 means full width)
zIndexNumber1000Defines the z-index of the scroll bar

Events

nameReturn typeDescription
scrolledpercentageFired continuously while scrolling, returns the scroll percentage (0-100)
scrollingbooleanFired when scrolling state changes (starts or stops), returns true when scrolling and false when at the top