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
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')
To use, simply call the component, in this case it will be NbPageScrollBar or nb-page-scroll-bar.
Important: The
NbPageScrollBarcomponent usesposition: fixedand 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>
Preview & Playground
Select the component you want to edit/test
Loading Sandbox...
Props
Items with an (*) mean they are required
| name | Value type | Default | Description |
|---|---|---|---|
| nbId (*) | String | Sets the id attribute to differentiate from other components | |
| ariaLabel | String | 'Alternate Text Button' | Defines the aria-label attribute for screen readers |
| ariaAttrs | Object | {} | Allows passing custom aria attributes as an object. Keys will automatically receive the aria- prefix |
| backgroundColor | String | 'transparent' | Defines the background color of the container. Accepts Color name, Hex, and RGB |
| progressColor | String | '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 |
| height | Number | 2 | Defines the height of the scroll bar in pixels |
| borderRadius | Number | 0.5 | Defines the border radius in rem units |
| position | String | 'top' | Defines the position of the scroll bar. Accepts top and bottom |
| top | Number | 0 | Defines the top offset in pixels (when position is 'top') |
| bottom | Number | 0 | Defines the bottom offset in pixels (when position is 'bottom') |
| left | Number | -1 | Defines the left offset in pixels (-1 means full width) |
| right | Number | -1 | Defines the right offset in pixels (-1 means full width) |
| zIndex | Number | 1000 | Defines the z-index of the scroll bar |
Events
| name | Return type | Description |
|---|---|---|
| scrolled | percentage | Fired continuously while scrolling, returns the scroll percentage (0-100) |
| scrolling | boolean | Fired when scrolling state changes (starts or stops), returns true when scrolling and false when at the top |
Table of Contents
