ScrollBar - Documentation | www.HtmlElements.com

Overview

A scroll bar is a numeric control used to select a numeric value from a range of values by moving a thumb along a track or by clicking on the track itself. It is typically used in conjucntion with the listbox and dropdown elements to allow scrolling through the items. The user can change the value by clicking in the tank area if it is set as an input element.

Getting Started with ScrollBar Web Component

Smart UI for Web Components is distributed as smart-webcomponents NPM package. You can also get the full download from our website with all demos from the Download page.

Setup the ScrollBar

Smart UI for Web Components is distributed as smart-webcomponents NPM package

  1. Download and install the package.

    npm install smart-webcomponents

  2. Once installed, import the ScrollBar module in your application.

    <script type="module" src="node_modules/smart-webcomponents/source/modules/smart.scrollbar.js"></script>

  3. Adding CSS reference

    The smart.default.css CSS file should be referenced using following code.

    <link rel="stylesheet" type="text/css" href="node_modules/smart-webcomponents/source/styles/smart.default.css" />

  4. Add the ScrollBar tag to your Web Page

    <smart-scroll-bar id="scrollbar"></smart-scroll-bar>

  5. Create the ScrollBar Component

    	<script type="module">
    		Smart('#scrollbar', class {
    			get properties() {
    				return {value: 50}
    			}
    		});
    	</script>	   
    		

    Another option is to create the ScrollBar is by using the traditional Javascript way:
    	const scrollbar = document.createElement('smart-scroll-bar');
    
    	scrollbar.disabled = true;
    	document.body.appendChild(scrollbar);
    		

    Smart framework provides a way to dynamically create a web component on demand from a DIV tag which is used as a host. The following imports the web component's module and creates it on demand, when the document is ready. The #scrollbar is the ID of a DIV tag.

    	import "../../source/modules/smart.scrollbar.js";
    
    	document.readyState === 'complete' ? init() : window.onload = init;
    
    	function init() { 
    		const scrollbar = new Smart.ScrollBar('#scrollbar', {value: 50});
    	}
    	

  6. Open the page in your web server.

Appearance

The scroll bar can be horizontal or vertical. This could be set via orientation property.

 <smart-scroll-bar orientation="vertical"></smart-scroll-bar>

Demo

Behavior

Scrollbar's range is defined by min and max properties.

When scrollbar's button is pressed, the value is increased/decreased by value, defined in step property.

If the user press the left mouse button in the area between a scrollbar button and thumb the value is increased/decreased by the value of largeStep property.

 <smart-scroll-bar min="0" max="100" step="10" large-step="20"></smart-scroll-bar>

Demo

Styling

Smart.ScrollBar uses the following CSS variables for styling:

  • --smart-scroll-button-size: used to set the size of the scroll buttons. Default value is 16px.

Create, Append, Remove, Get/Set Property, Invoke Method, Bind to Event


Create a new element:
	const scrollbar = document.createElement('smart-scroll-bar');
	

Append it to the DOM:
	document.body.appendChild(scrollbar);
	

Remove it from the DOM:
	scrollbar.parentNode.removeChild(scrollbar);
	

Set a property:
	scrollbar.propertyName = propertyValue;
	

Get a property value:
	const propertyValue = scrollbar.propertyName;
	

Invoke a method:
	scrollbar.methodName(argument1, argument2);
	

Add Event Listener:
	const eventHandler = (event) => {
	   // your code here.
	};

	scrollbar.addEventListener(eventName, eventHandler);
	

Remove Event Listener:
	scrollbar.removeEventListener(eventName, eventHandler, true);
	

Using with Typescript

Smart Web Components package includes TypeScript definitions which enables strongly-typed access to the Smart UI Components and their configuration.

Inside the download package, the typescript directory contains .d.ts file for each web component and a smart.elements.d.ts typescript definitions file for all web components. Copy the typescript definitions file to your project and in your TypeScript file add a reference to smart.elements.d.ts

Read more about using Smart UI with Typescript.

Getting Started with Angular ScrollBar Component

Setup Angular Environment

Angular provides the easiest way to set angular CLI projects using Angular CLI tool.

Install the CLI application globally to your machine.

npm install -g @angular/cli

Create a new Application

ng new smart-angular-scrollbar

Navigate to the created project folder

cd smart-angular-scrollbar

Setup the ScrollBar

Smart UI for Angular is distributed as smart-webcomponents-angular NPM package

  1. Download and install the package.
    npm install smart-webcomponents-angular
  2. Adding CSS reference

    The following CSS file is available in ../node_modules/smart-webcomponents-angular/ package folder. This can be referenced in [src/styles.css] using following code.

    @import 'smart-webcomponents-angular/source/styles/smart.default.css';

    Another way to achieve the same is to edit the angular.json file and in the styles add the style.

    "styles": [
    		"node_modules/smart-webcomponents-angular/source/styles/smart.default.css"
    	]
    If you want to use Bootstrap, Fluent or other themes available in the package, you need to add them after 'smart.default.css'.
  3. Example with Angular Standalone Components


    app.component.html

     <section>
      <div>
        <h2>Scrollbars let users to select values by moving the scrollbar thumb.</h2>
        <div class="module">
          <p>Scrollbars are ideal components for adjusting settings that reflect intensity
            levels, such as volume, brightness, or color saturation.</p>
        </div>
      </div>
    </section>
    <section id="continuousSliders">
      <h2>Continuous scrollbar</h2>
      <div class="module">
        <p>Use continuous scrollbars for subjective settings that do not require
          a specific value for the user to make meaningful adjustments.</p>
      </div>
      <div class="module continuousSliderLight">
        <table>
          <tr>
            <td>
              <p>Normal</p>
            </td>
          </tr>
          <tr>
            <td>
              <smart-scroll-bar #scrollbar></smart-scroll-bar>
            </td>
          </tr>
          <tr>
            <td>
              <smart-scroll-bar #scrollbar2 [max]="100" [value]="50"></smart-scroll-bar>
            </td>
          </tr>
          <tr>
            <td>
              <smart-scroll-bar #scrollbar3 [max]="100" [value]="100"></smart-scroll-bar>
            </td>
          </tr>
          <tr>
            <td>
              <p>Disabled</p>
            </td>
          </tr>
          <tr>
            <td>
              <smart-scroll-bar #scrollbar4 [disabled]="true" [max]="100"></smart-scroll-bar>
            </td>
          </tr>
          <tr>
            <td>
              <smart-scroll-bar #scrollbar5 [disabled]="true" [max]="100" [value]="50"></smart-scroll-bar>
            </td>
          </tr>
          <tr>
            <td>
              <smart-scroll-bar #scrollbar6 [disabled]="true" [max]="100" [value]="100"></smart-scroll-bar>
            </td>
          </tr>
        </table>
      </div>
    </section>
    <section id="verticalSliders">
      <h2>Orientation</h2>
      <div class="module">
        <p>smartScrollBar can be horizontal or vertical depending on the orientation
          property.</p>
      </div>
      <div class="module">
        <div>
          <smart-scroll-bar #scrollbar7 [max]="100" [value]="50"></smart-scroll-bar>
          <br/>
          <br/>
          <smart-scroll-bar #scrollbar8 orientation="vertical" [max]="100" [value]="75"></smart-scroll-bar>
        </div>
        <br/>
        <p>Vertical scrollbars</p>
      </div>
    </section>
    <section id="demoSliders">
      <h2>Demo</h2>
      <div class="module">
        <p>ScrollBars are controls that are used for adjusting values precisely.</p>
      </div>
      <div class="module media-controls">
        <div>
          <h2>Volumes</h2>
          <div>
            <h3>Media volume</h3>
            <div id="mediaControl" class="controls"> <i class="material-icons">&#xE04D;</i>
              <smart-scroll-bar #scrollbar9 id="mediaSlider" [max]="100" [value]="25"></smart-scroll-bar>
            </div>
          </div>
          <div>
            <h3>Alarm volume</h3>
            <div id="alarmControl" class="controls"> <i class="material-icons">&#xE855;</i>
              <smart-scroll-bar #scrollbar10 id="alarmSlider" [max]="100" [value]="50"></smart-scroll-bar>
            </div>
          </div>
          <div>
            <h3>Ring volume</h3>
            <div id="ringControl" class="controls"> <i class="material-icons">&#xE7F4;</i>
              <smart-scroll-bar #scrollbar11 id="volumeSlider" [max]="100" [value]="75"></smart-scroll-bar>
            </div>
          </div>
        </div>
      </div>
      <div class="module power-controls">
        <div>
          <h2>Battery Saver Mode</h2>
          <div>
            <h3>Low battery alert on <b id="lowBatteryAlert">15</b> %</h3>
            <div id="mediaControl" class="controls"> <i class="material-icons">&#xE8B2;</i>
              <smart-scroll-bar #scrollbar12 id="lowBatterySlider" [max]="100" [value]="15" scale-type="integer">
              </smart-scroll-bar>
            </div>
          </div>
          <div>
            <h3>Power saver mode active on <b id="powerSaver">50</b>%</h3>
            <div id="alarmControl" class="controls"> <i class="material-icons">&#xE19C;</i>
              <smart-scroll-bar #scrollbar13 id="powerSaverSlider" [max]="100" [value]="50" scale-type="integer">
              </smart-scroll-bar>
            </div>
          </div>
        </div>
      </div>
    </section>

    app.component.ts

     import { Component, ViewChild, OnInit, AfterViewInit } from '@angular/core';
    import { ScrollBarComponent, ScrollBar } from 'smart-webcomponents-angular/scrollbar';
    
    import { CommonModule } from '@angular/common';
    import { RouterOutlet } from '@angular/router';
    import { ScrollBarModule } from 'smart-webcomponents-angular/scrollbar';
    
    @Component({
        selector: 'app-root',
    	standalone: true,
    	imports: [CommonModule, ScrollBarModule, RouterOutlet],
        templateUrl: './app.component.html',
        styleUrls: ['./app.component.css']
    })
    
    export class AppComponent implements AfterViewInit, OnInit {
        @ViewChild('scrollbar', { read: ScrollBarComponent, static: false }) scrollbar!: ScrollBarComponent;
        @ViewChild('scrollbar2', { read: ScrollBarComponent, static: false }) scrollbar2!: ScrollBarComponent;
        @ViewChild('scrollbar3', { read: ScrollBarComponent, static: false }) scrollbar3!: ScrollBarComponent;
        @ViewChild('scrollbar4', { read: ScrollBarComponent, static: false }) scrollbar4!: ScrollBarComponent;
        @ViewChild('scrollbar5', { read: ScrollBarComponent, static: false }) scrollbar5!: ScrollBarComponent;
        @ViewChild('scrollbar6', { read: ScrollBarComponent, static: false }) scrollbar6!: ScrollBarComponent;
        @ViewChild('scrollbar7', { read: ScrollBarComponent, static: false }) scrollbar7!: ScrollBarComponent;
        @ViewChild('scrollbar8', { read: ScrollBarComponent, static: false }) scrollbar8!: ScrollBarComponent;
        @ViewChild('scrollbar9', { read: ScrollBarComponent, static: false }) scrollbar9!: ScrollBarComponent;
        @ViewChild('scrollbar10', { read: ScrollBarComponent, static: false }) scrollbar10!: ScrollBarComponent;
        @ViewChild('scrollbar11', { read: ScrollBarComponent, static: false }) scrollbar11!: ScrollBarComponent;
        @ViewChild('scrollbar12', { read: ScrollBarComponent, static: false }) scrollbar12!: ScrollBarComponent;
        @ViewChild('scrollbar13', { read: ScrollBarComponent, static: false }) scrollbar13!: ScrollBarComponent;
    
    
        ngOnInit(): void {
            // onInit code.
        }
    
        ngAfterViewInit(): void {
            // afterViewInit code.
            this.init();
        }
    
        init(): void {
            // init code.
    
    
            const mediaSlider = document.getElementById('mediaSlider')
            const alarmSlider = document.getElementById('alarmSlider')
            const volumeSlider = document.getElementById('volumeSlider')
            const lowBatterySlider = document.getElementById('lowBatterySlider')
            const powerSaverSlider = document.getElementById('powerSaverSlider');
    
            function setIcon(event: CustomEvent) {
                let below = "", above = "", off = "";
                const slider = event.target as ScrollBar;
                switch (slider) {
                    case mediaSlider:
                        below = '';
                        above = '';
                        off = '';
                        break;
                    case alarmSlider:
                        below = above = '';
                        off = '';
                        break;
                    case volumeSlider:
                        below = '';
                        above = '';
                        off = '';
                        break;
                }
    
                if (!slider.previousElementSibling) { return }
    
                if (slider.value === slider.min) {
                    slider.previousElementSibling.innerHTML = off;
                }
                else if (slider.value || 0 < (slider.max || 0) / 2) {
                    slider.previousElementSibling.innerHTML = below;
                }
                else {
                    slider.previousElementSibling.innerHTML = above;
                }
            }
            function setBatteryLevel(event: Event) {
                const slider = event.target;
                if (slider === lowBatterySlider && document.getElementById('lowBatteryAlert')) {
                    document.getElementById('lowBatteryAlert')!.textContent = slider.value?.toString() || '';
                }
                else {
                    if (document.getElementById('powerSaver')) {
                        document.getElementById('powerSaver')!.textContent = slider.value?.toString() || '';
                    }
                }
            }
            mediaSlider?.addEventListener('change', setIcon as EventListener);
            alarmSlider?.addEventListener('change', setIcon as EventListener);
            volumeSlider?.addEventListener('change', setIcon as EventListener);
            lowBatterySlider?.addEventListener('change', setBatteryLevel);
            powerSaverSlider?.addEventListener('change', setBatteryLevel);
    
    
        }
    }

  4. Example with Angular NGModule


    app.component.html

     <section>
      <div>
        <h2>Scrollbars let users to select values by moving the scrollbar thumb.</h2>
        <div class="module">
          <p>Scrollbars are ideal components for adjusting settings that reflect intensity
            levels, such as volume, brightness, or color saturation.</p>
        </div>
      </div>
    </section>
    <section id="continuousSliders">
      <h2>Continuous scrollbar</h2>
      <div class="module">
        <p>Use continuous scrollbars for subjective settings that do not require
          a specific value for the user to make meaningful adjustments.</p>
      </div>
      <div class="module continuousSliderLight">
        <table>
          <tr>
            <td>
              <p>Normal</p>
            </td>
          </tr>
          <tr>
            <td>
              <smart-scroll-bar #scrollbar></smart-scroll-bar>
            </td>
          </tr>
          <tr>
            <td>
              <smart-scroll-bar #scrollbar2 [max]="100" [value]="50"></smart-scroll-bar>
            </td>
          </tr>
          <tr>
            <td>
              <smart-scroll-bar #scrollbar3 [max]="100" [value]="100"></smart-scroll-bar>
            </td>
          </tr>
          <tr>
            <td>
              <p>Disabled</p>
            </td>
          </tr>
          <tr>
            <td>
              <smart-scroll-bar #scrollbar4 [disabled]="true" [max]="100"></smart-scroll-bar>
            </td>
          </tr>
          <tr>
            <td>
              <smart-scroll-bar #scrollbar5 [disabled]="true" [max]="100" [value]="50"></smart-scroll-bar>
            </td>
          </tr>
          <tr>
            <td>
              <smart-scroll-bar #scrollbar6 [disabled]="true" [max]="100" [value]="100"></smart-scroll-bar>
            </td>
          </tr>
        </table>
      </div>
    </section>
    <section id="verticalSliders">
      <h2>Orientation</h2>
      <div class="module">
        <p>smartScrollBar can be horizontal or vertical depending on the orientation
          property.</p>
      </div>
      <div class="module">
        <div>
          <smart-scroll-bar #scrollbar7 [max]="100" [value]="50"></smart-scroll-bar>
          <br/>
          <br/>
          <smart-scroll-bar #scrollbar8 orientation="vertical" [max]="100" [value]="75"></smart-scroll-bar>
        </div>
        <br/>
        <p>Vertical scrollbars</p>
      </div>
    </section>
    <section id="demoSliders">
      <h2>Demo</h2>
      <div class="module">
        <p>ScrollBars are controls that are used for adjusting values precisely.</p>
      </div>
      <div class="module media-controls">
        <div>
          <h2>Volumes</h2>
          <div>
            <h3>Media volume</h3>
            <div id="mediaControl" class="controls"> <i class="material-icons">&#xE04D;</i>
              <smart-scroll-bar #scrollbar9 id="mediaSlider" [max]="100" [value]="25"></smart-scroll-bar>
            </div>
          </div>
          <div>
            <h3>Alarm volume</h3>
            <div id="alarmControl" class="controls"> <i class="material-icons">&#xE855;</i>
              <smart-scroll-bar #scrollbar10 id="alarmSlider" [max]="100" [value]="50"></smart-scroll-bar>
            </div>
          </div>
          <div>
            <h3>Ring volume</h3>
            <div id="ringControl" class="controls"> <i class="material-icons">&#xE7F4;</i>
              <smart-scroll-bar #scrollbar11 id="volumeSlider" [max]="100" [value]="75"></smart-scroll-bar>
            </div>
          </div>
        </div>
      </div>
      <div class="module power-controls">
        <div>
          <h2>Battery Saver Mode</h2>
          <div>
            <h3>Low battery alert on <b id="lowBatteryAlert">15</b> %</h3>
            <div id="mediaControl" class="controls"> <i class="material-icons">&#xE8B2;</i>
              <smart-scroll-bar #scrollbar12 id="lowBatterySlider" [max]="100" [value]="15" scale-type="integer">
              </smart-scroll-bar>
            </div>
          </div>
          <div>
            <h3>Power saver mode active on <b id="powerSaver">50</b>%</h3>
            <div id="alarmControl" class="controls"> <i class="material-icons">&#xE19C;</i>
              <smart-scroll-bar #scrollbar13 id="powerSaverSlider" [max]="100" [value]="50" scale-type="integer">
              </smart-scroll-bar>
            </div>
          </div>
        </div>
      </div>
    </section>

    app.component.ts

     import { Component, ViewChild, OnInit, AfterViewInit } from '@angular/core';
    import { ScrollBarComponent, ScrollBar } from 'smart-webcomponents-angular/scrollbar';
    
    @Component({
        selector: 'app-root',
        templateUrl: './app.component.html',
        styleUrls: ['./app.component.css']
    })
    
    export class AppComponent implements AfterViewInit, OnInit {
        @ViewChild('scrollbar', { read: ScrollBarComponent, static: false }) scrollbar!: ScrollBarComponent;
        @ViewChild('scrollbar2', { read: ScrollBarComponent, static: false }) scrollbar2!: ScrollBarComponent;
        @ViewChild('scrollbar3', { read: ScrollBarComponent, static: false }) scrollbar3!: ScrollBarComponent;
        @ViewChild('scrollbar4', { read: ScrollBarComponent, static: false }) scrollbar4!: ScrollBarComponent;
        @ViewChild('scrollbar5', { read: ScrollBarComponent, static: false }) scrollbar5!: ScrollBarComponent;
        @ViewChild('scrollbar6', { read: ScrollBarComponent, static: false }) scrollbar6!: ScrollBarComponent;
        @ViewChild('scrollbar7', { read: ScrollBarComponent, static: false }) scrollbar7!: ScrollBarComponent;
        @ViewChild('scrollbar8', { read: ScrollBarComponent, static: false }) scrollbar8!: ScrollBarComponent;
        @ViewChild('scrollbar9', { read: ScrollBarComponent, static: false }) scrollbar9!: ScrollBarComponent;
        @ViewChild('scrollbar10', { read: ScrollBarComponent, static: false }) scrollbar10!: ScrollBarComponent;
        @ViewChild('scrollbar11', { read: ScrollBarComponent, static: false }) scrollbar11!: ScrollBarComponent;
        @ViewChild('scrollbar12', { read: ScrollBarComponent, static: false }) scrollbar12!: ScrollBarComponent;
        @ViewChild('scrollbar13', { read: ScrollBarComponent, static: false }) scrollbar13!: ScrollBarComponent;
    
    
        ngOnInit(): void {
            // onInit code.
        }
    
        ngAfterViewInit(): void {
            // afterViewInit code.
            this.init();
        }
    
        init(): void {
            // init code.
    
    
            const mediaSlider = document.getElementById('mediaSlider')
            const alarmSlider = document.getElementById('alarmSlider')
            const volumeSlider = document.getElementById('volumeSlider')
            const lowBatterySlider = document.getElementById('lowBatterySlider')
            const powerSaverSlider = document.getElementById('powerSaverSlider');
    
            function setIcon(event: CustomEvent) {
                let below = "", above = "", off = "";
                const slider = event.target as ScrollBar;
                switch (slider) {
                    case mediaSlider:
                        below = '';
                        above = '';
                        off = '';
                        break;
                    case alarmSlider:
                        below = above = '';
                        off = '';
                        break;
                    case volumeSlider:
                        below = '';
                        above = '';
                        off = '';
                        break;
                }
    
                if (!slider.previousElementSibling) { return }
    
                if (slider.value === slider.min) {
                    slider.previousElementSibling.innerHTML = off;
                }
                else if (slider.value || 0 < (slider.max || 0) / 2) {
                    slider.previousElementSibling.innerHTML = below;
                }
                else {
                    slider.previousElementSibling.innerHTML = above;
                }
            }
            function setBatteryLevel(event: Event) {
                const slider = event.target;
                if (slider === lowBatterySlider && document.getElementById('lowBatteryAlert')) {
                    document.getElementById('lowBatteryAlert')!.textContent = slider.value?.toString() || '';
                }
                else {
                    if (document.getElementById('powerSaver')) {
                        document.getElementById('powerSaver')!.textContent = slider.value?.toString() || '';
                    }
                }
            }
            mediaSlider?.addEventListener('change', setIcon as EventListener);
            alarmSlider?.addEventListener('change', setIcon as EventListener);
            volumeSlider?.addEventListener('change', setIcon as EventListener);
            lowBatterySlider?.addEventListener('change', setBatteryLevel);
            powerSaverSlider?.addEventListener('change', setBatteryLevel);
    
    
        }
    }

    app.module.ts

     import { NgModule } from '@angular/core';
    import { BrowserModule } from '@angular/platform-browser';
    
    import { ScrollBarModule } from 'smart-webcomponents-angular/scrollbar';
    
    import { AppComponent } from './app.component';
    
    @NgModule({
        declarations: [ AppComponent ],
        imports: [ BrowserModule, ScrollBarModule ],
        bootstrap: [ AppComponent ]
    })
    
    export class AppModule { }


Running the Angular application

After completing the steps required to render a ScrollBar, run the following command to display the output in your web browser

ng serve
and open localhost:4200 in your favorite web browser.

Read more about using Smart UI for Angular: https://www.htmlelements.com/docs/angular-cli/.

Getting Started with React ScrollBar Component

Setup React Environment

The easiest way to start with React is to use NextJS Next.js is a full-stack React framework. It’s versatile and lets you create React apps of any size—from a mostly static blog to a complex dynamic application.

npx create-next-app my-app
cd my-app
npm run dev	
or
yarn create next-app my-app
cd my-app
yarn run dev

Preparation

Setup the ScrollBar

Smart UI for React is distributed as smart-webcomponents-react package

  1. Download and install the package.

    In your React Next.js project, run one of the following commands to install Smart UI ScrollBar for React

    With NPM:

    npm install smart-webcomponents-react
    With Yarn:
    yarn add smart-webcomponents-react

  2. Once installed, import the React ScrollBar Component and CSS files in your application and render it. app.js

    import 'smart-webcomponents-react/source/styles/smart.default.css';
    import React from "react";
    import ReactDOM from 'react-dom/client';
    import { ScrollBar } from 'smart-webcomponents-react/scrollbar';
    
    class App extends React.Component {
    	constructor(p) {
    		super(p);
    
    		this.scrollbar = React.createRef();
    		this.scrollbar2 = React.createRef();
    		this.scrollbar3 = React.createRef();
    		this.scrollbar4 = React.createRef();
    		this.scrollbar5 = React.createRef();
    		this.lowbatteryalert = React.createRef();
    		this.powersaver = React.createRef();
    	}
    
    	setIcon(sliderName, event) {
    		const that = this;
    		let below = "",
    			above = "",
    			off = "",
    			slider;
    
    		switch (sliderName) {
    			case 'mediaSlider':
    				below = '<i className="material-icons">&#xE04D;</i>';
    				above = '<i className="material-icons">&#xE050;</i>';
    				off = '<i className="material-icons">&#xE04F;</i>';
    				slider = that.scrollbar.current;
    				break;
    			case 'alarmSlider':
    				below = above = '<i className="material-icons">&#xE855;</i>';
    				off = '<i className="material-icons">&#xE857;</i>';
    				slider = that.scrollbar2.current;
    				break;
    			case 'volumeSlider':
    				below = '<i className="material-icons">&#xE7F5;</i>';
    				above = '<i className="material-icons">&#xE7F4;</i>';
    				off = '<i className="material-icons">&#xE7F6;</i>';
    				slider = that.scrollbar3.current;
    				break;
    		}
    
    		if (slider.value === slider.min) {
    			slider.nativeElement.previousElementSibling.innerHTML = off;
    		}
    		else if (slider.value < slider.max / 2) {
    			slider.nativeElement.previousElementSibling.innerHTML = below;
    		}
    		else {
    			slider.nativeElement.previousElementSibling.innerHTML = above;
    		}
    	}
    
    	setBatteryLevel(sliderName, event) {
    		const that = this;
    		const slider = (sliderName === 'lowBatterySlider' ? that.scrollbar4 : that.scrollbar5).current,
    			lowBatterySlider = that.scrollbar4.current;
    
    		if (slider === lowBatterySlider) {
    			this.lowbatteryalert.current.textContent = slider.value.toString();
    		}
    		else {
    			this.powersaver.current.textContent = slider.value.toString();
    		}
    	}
    
    	componentDidMount() {
    
    	}
    
    	render() {
    		return (
    			<div>
    				<section>
    					<div>
    						<h2>Scrollbars let users to select values by moving the scrollbar thumb.</h2>
    						<div className="module">
    							<p>Scrollbars are ideal components for adjusting settings that reflect intensity
    			                    levels, such as volume, brightness, or color saturation.</p>
    						</div>
    					</div>
    				</section>
    				<section id="continuousSliders">
    					<h2>Continuous scrollbar</h2>
    					<div className="module">
    						<p>Use continuous scrollbars for subjective settings that do not require
    			                a specific value for the user to make meaningful adjustments.</p>
    					</div>
    					<div className="module continuousSliderLight">
    						<table>
    							<tr>
    								<td>
    									<p>Normal</p>
    								</td>
    							</tr>
    							<tr>
    								<td>
    									<ScrollBar ></ScrollBar>
    								</td>
    							</tr>
    							<tr>
    								<td>
    									<ScrollBar max={100} value={50}></ScrollBar>
    								</td>
    							</tr>
    							<tr>
    								<td>
    									<ScrollBar max={100} value={100}></ScrollBar>
    								</td>
    							</tr>
    							<tr>
    								<td>
    									<p>Disabled</p>
    								</td>
    							</tr>
    							<tr>
    								<td>
    									<ScrollBar disabled max={100}></ScrollBar>
    								</td>
    							</tr>
    							<tr>
    								<td>
    									<ScrollBar disabled max={100} value={50}></ScrollBar>
    								</td>
    							</tr>
    							<tr>
    								<td>
    									<ScrollBar disabled max={100} value={100}></ScrollBar>
    								</td>
    							</tr>
    						</table>
    					</div>
    				</section>
    				<section id="verticalSliders">
    					<h2>Orientation</h2>
    					<div className="module">
    						<p>smartScrollBar can be horizontal or vertical depending on the orientation
    			                property.</p>
    					</div>
    					<div className="module">
    						<div>
    							<ScrollBar max={100} value={50}></ScrollBar>
    							<br />
    							<br />
    							<ScrollBar orientation="vertical" max={100} value={75}></ScrollBar>
    						</div>
    						<br />
    						<p>Vertical scrollbars</p>
    					</div>
    				</section>
    				<section id="demoSliders">
    					<h2>Demo</h2>
    					<div className="module">
    						<p>ScrollBars are controls that are used for adjusting values precisely.</p>
    					</div>
    					<div className="module media-controls">
    						<div>
    							<h2>Volumes</h2>
    							<div>
    								<h3>Media volume</h3>
    								<div id="mediaControl" className="controls"> <i className="material-icons">&#xE04D;</i>
    									<ScrollBar ref={this.scrollbar} id="mediaSlider" onChange={this.setIcon.bind(this, 'mediaSlider')}
    										max={100} value={25}></ScrollBar>
    								</div>
    							</div>
    							<div>
    								<h3>Alarm volume</h3>
    								<div id="alarmControl" className="controls"> <i className="material-icons">&#xE855;</i>
    									<ScrollBar ref={this.scrollbar2} id="alarmSlider" onChange={this.setIcon.bind(this, 'alarmSlider')}
    										max={100} value={50}></ScrollBar>
    								</div>
    							</div>
    							<div>
    								<h3>Ring volume</h3>
    								<div id="ringControl" className="controls"> <i className="material-icons">&#xE7F4;</i>
    									<ScrollBar ref={this.scrollbar3} id="volumeSlider" onChange={this.setIcon.bind(this, 'volumeSlider')}
    										max={100} value={75}></ScrollBar>
    								</div>
    							</div>
    						</div>
    					</div>
    					<div className="module power-controls">
    						<div>
    							<h2>Battery Saver Mode</h2>
    							<div>
    								<h3>Low battery alert on <b ref={this.lowbatteryalert}  id="lowBatteryAlert">15</b> %</h3>
    								<div id="mediaControl" className="controls"> <i className="material-icons">&#xE8B2;</i>
    									<ScrollBar ref={this.scrollbar4} id="lowBatterySlider" onChange={this.setBatteryLevel.bind(this, 'lowBatterySlider')}
    										max={100} value={15} scaleType="integer"></ScrollBar>
    								</div>
    							</div>
    							<div>
    								<h3>Power saver mode active on <b ref={this.powersaver} id="powerSaver">50</b>%</h3>
    								<div id="alarmControl" className="controls"> <i className="material-icons">&#xE19C;</i>
    									<ScrollBar ref={this.scrollbar5} id="powerSaverSlider" onChange={this.setBatteryLevel.bind(this, 'powerSaverSlider')}
    										max={100} value={50} scaleType="integer"></ScrollBar>
    								</div>
    							</div>
    						</div>
    					</div>
    				</section>
    			</div>
    		);
    	}
    }
    
    
    
    export default App;
    	

Running the React application

Start the app with
npm run dev
or
yarn run dev
and open localhost:3000 in your favorite web browser to see the output.

Setup with Vite

Vite (French word for "quick", pronounced /vit/, like "veet") is a build tool that aims to provide a faster and leaner development experience for modern web projects
With NPM:
npm create vite@latest
With Yarn:
yarn create vite
Then follow the prompts and choose React as a project.

Navigate to your project's directory. By default it is 'vite-project' and install Smart UI for React

In your Vite project, run one of the following commands to install Smart UI ScrollBar for React

With NPM:

npm install smart-webcomponents-react
With Yarn:
yarn add smart-webcomponents-react

Open src/App.tsx App.tsx

import 'smart-webcomponents-react/source/styles/smart.default.css';
import React from "react";
import ReactDOM from 'react-dom/client';
import { ScrollBar } from 'smart-webcomponents-react/scrollbar';

class App extends React.Component {
	constructor(p) {
		super(p);

		this.scrollbar = React.createRef();
		this.scrollbar2 = React.createRef();
		this.scrollbar3 = React.createRef();
		this.scrollbar4 = React.createRef();
		this.scrollbar5 = React.createRef();
		this.lowbatteryalert = React.createRef();
		this.powersaver = React.createRef();
	}

	setIcon(sliderName, event) {
		const that = this;
		let below = "",
			above = "",
			off = "",
			slider;

		switch (sliderName) {
			case 'mediaSlider':
				below = '<i className="material-icons">&#xE04D;</i>';
				above = '<i className="material-icons">&#xE050;</i>';
				off = '<i className="material-icons">&#xE04F;</i>';
				slider = that.scrollbar.current;
				break;
			case 'alarmSlider':
				below = above = '<i className="material-icons">&#xE855;</i>';
				off = '<i className="material-icons">&#xE857;</i>';
				slider = that.scrollbar2.current;
				break;
			case 'volumeSlider':
				below = '<i className="material-icons">&#xE7F5;</i>';
				above = '<i className="material-icons">&#xE7F4;</i>';
				off = '<i className="material-icons">&#xE7F6;</i>';
				slider = that.scrollbar3.current;
				break;
		}

		if (slider.value === slider.min) {
			slider.nativeElement.previousElementSibling.innerHTML = off;
		}
		else if (slider.value < slider.max / 2) {
			slider.nativeElement.previousElementSibling.innerHTML = below;
		}
		else {
			slider.nativeElement.previousElementSibling.innerHTML = above;
		}
	}

	setBatteryLevel(sliderName, event) {
		const that = this;
		const slider = (sliderName === 'lowBatterySlider' ? that.scrollbar4 : that.scrollbar5).current,
			lowBatterySlider = that.scrollbar4.current;

		if (slider === lowBatterySlider) {
			this.lowbatteryalert.current.textContent = slider.value.toString();
		}
		else {
			this.powersaver.current.textContent = slider.value.toString();
		}
	}

	componentDidMount() {

	}

	render() {
		return (
			<div>
				<section>
					<div>
						<h2>Scrollbars let users to select values by moving the scrollbar thumb.</h2>
						<div className="module">
							<p>Scrollbars are ideal components for adjusting settings that reflect intensity
			                    levels, such as volume, brightness, or color saturation.</p>
						</div>
					</div>
				</section>
				<section id="continuousSliders">
					<h2>Continuous scrollbar</h2>
					<div className="module">
						<p>Use continuous scrollbars for subjective settings that do not require
			                a specific value for the user to make meaningful adjustments.</p>
					</div>
					<div className="module continuousSliderLight">
						<table>
							<tr>
								<td>
									<p>Normal</p>
								</td>
							</tr>
							<tr>
								<td>
									<ScrollBar ></ScrollBar>
								</td>
							</tr>
							<tr>
								<td>
									<ScrollBar max={100} value={50}></ScrollBar>
								</td>
							</tr>
							<tr>
								<td>
									<ScrollBar max={100} value={100}></ScrollBar>
								</td>
							</tr>
							<tr>
								<td>
									<p>Disabled</p>
								</td>
							</tr>
							<tr>
								<td>
									<ScrollBar disabled max={100}></ScrollBar>
								</td>
							</tr>
							<tr>
								<td>
									<ScrollBar disabled max={100} value={50}></ScrollBar>
								</td>
							</tr>
							<tr>
								<td>
									<ScrollBar disabled max={100} value={100}></ScrollBar>
								</td>
							</tr>
						</table>
					</div>
				</section>
				<section id="verticalSliders">
					<h2>Orientation</h2>
					<div className="module">
						<p>smartScrollBar can be horizontal or vertical depending on the orientation
			                property.</p>
					</div>
					<div className="module">
						<div>
							<ScrollBar max={100} value={50}></ScrollBar>
							<br />
							<br />
							<ScrollBar orientation="vertical" max={100} value={75}></ScrollBar>
						</div>
						<br />
						<p>Vertical scrollbars</p>
					</div>
				</section>
				<section id="demoSliders">
					<h2>Demo</h2>
					<div className="module">
						<p>ScrollBars are controls that are used for adjusting values precisely.</p>
					</div>
					<div className="module media-controls">
						<div>
							<h2>Volumes</h2>
							<div>
								<h3>Media volume</h3>
								<div id="mediaControl" className="controls"> <i className="material-icons">&#xE04D;</i>
									<ScrollBar ref={this.scrollbar} id="mediaSlider" onChange={this.setIcon.bind(this, 'mediaSlider')}
										max={100} value={25}></ScrollBar>
								</div>
							</div>
							<div>
								<h3>Alarm volume</h3>
								<div id="alarmControl" className="controls"> <i className="material-icons">&#xE855;</i>
									<ScrollBar ref={this.scrollbar2} id="alarmSlider" onChange={this.setIcon.bind(this, 'alarmSlider')}
										max={100} value={50}></ScrollBar>
								</div>
							</div>
							<div>
								<h3>Ring volume</h3>
								<div id="ringControl" className="controls"> <i className="material-icons">&#xE7F4;</i>
									<ScrollBar ref={this.scrollbar3} id="volumeSlider" onChange={this.setIcon.bind(this, 'volumeSlider')}
										max={100} value={75}></ScrollBar>
								</div>
							</div>
						</div>
					</div>
					<div className="module power-controls">
						<div>
							<h2>Battery Saver Mode</h2>
							<div>
								<h3>Low battery alert on <b ref={this.lowbatteryalert}  id="lowBatteryAlert">15</b> %</h3>
								<div id="mediaControl" className="controls"> <i className="material-icons">&#xE8B2;</i>
									<ScrollBar ref={this.scrollbar4} id="lowBatterySlider" onChange={this.setBatteryLevel.bind(this, 'lowBatterySlider')}
										max={100} value={15} scaleType="integer"></ScrollBar>
								</div>
							</div>
							<div>
								<h3>Power saver mode active on <b ref={this.powersaver} id="powerSaver">50</b>%</h3>
								<div id="alarmControl" className="controls"> <i className="material-icons">&#xE19C;</i>
									<ScrollBar ref={this.scrollbar5} id="powerSaverSlider" onChange={this.setBatteryLevel.bind(this, 'powerSaverSlider')}
										max={100} value={50} scaleType="integer"></ScrollBar>
								</div>
							</div>
						</div>
					</div>
				</section>
			</div>
		);
	}
}



export default App;
	

Read more about using Smart UI for React: https://www.htmlelements.com/docs/react/.

Getting Started with Vue ScrollBar Component


Setup Vue with Vite

In this section we will introduce how to scaffold a Vue Single Page Application on your local machine. The created project will be using a build setup based on Vite and allow us to use Vue Single-File Components (SFCs). Run the following command in your command line
npm create vue@latest
This command will install and execute create-vue, the official Vue project scaffolding tool. You will be presented with prompts for several optional features such as TypeScript and testing support:
✔ Project name: … 
✔ Add TypeScript? … No / Yes
✔ Add JSX Support? … No / Yes
✔ Add Vue Router for Single Page Application development? … No / Yes
✔ Add Pinia for state management? … No / Yes
✔ Add Vitest for Unit testing? … No / Yes
✔ Add an End-to-End Testing Solution? … No / Cypress / Playwright
✔ Add ESLint for code quality? … No / Yes
✔ Add Prettier for code formatting? … No / Yes

Scaffolding project in ./...
Done.
If you are unsure about an option, simply choose No by hitting enter for now. Once the project is created, follow the instructions to install dependencies and start the dev server:
cd 
npm install
npm install smart-webcomponents
npm run dev
  • Make Vue ignore custom elements defined outside of Vue (e.g., using the Web Components APIs). Otherwise, it will throw a warning about an Unknown custom element, assuming that you forgot to register a global component or misspelled a component name.

    Open vite.config.js in your favorite text editor and change its contents to the following:

    vite.config.js

    import { fileURLToPath, URL } from 'node:url'
    
    import { defineConfig } from 'vite'
    import vue from '@vitejs/plugin-vue'
    
    // https://vitejs.dev/config/
    export default defineConfig({
      plugins: [
        vue({
          template: {
            compilerOptions: {
              isCustomElement: tag => tag.startsWith('smart-')
            }
          }
        })
      ],
      resolve: {
        alias: {
          '@': fileURLToPath(new URL('./src', import.meta.url))
        }
      }
    })
    		
  • Open src/App.vue in your favorite text editor and change its contents to the following:

    App.vue

    <template>
      <div class="vue-root">
        <section>
          <div>
            <h2>Scrollbars let users to select values by moving the scrollbar thumb.</h2>
            <div class="module">
              <p>Scrollbars are ideal components for adjusting settings that reflect intensity levels, such as volume, brightness, or color saturation.</p>
            </div>
          </div>
        </section>
    
        <section id="continuousSliders">
          <h2>Continuous scrollbar</h2>
          <div class="module">
            <p>Use continuous scrollbars for subjective settings that do not require a specific value for the user to make meaningful adjustments.</p>
          </div>
    
          <div class="module continuousSliderLight">
            <table>
              <tr>
                <td>
                  <p>Normal</p>
                </td>
              </tr>
              <tr />
              <tr>
                <td>
                  <smart-scroll-bar></smart-scroll-bar>
                </td>
              </tr>
              <tr />
              <tr>
                <td>
                  <smart-scroll-bar></smart-scroll-bar>
                </td>
              </tr>
              <tr />
              <tr>
                <td>
                  <smart-scroll-bar></smart-scroll-bar>
                </td>
              </tr>
              <tr>
                <td>
                  <p>Disabled</p>
                </td>
              </tr>
              <tr />
              <tr>
                <td>
                  <smart-scroll-bar disabled></smart-scroll-bar>
                </td>
              </tr>
              <tr />
              <tr>
                <td>
                  <smart-scroll-bar disabled></smart-scroll-bar>
                </td>
              </tr>
              <tr />
              <tr>
                <td>
                  <smart-scroll-bar disabled></smart-scroll-bar>
                </td>
              </tr>
            </table>
          </div>
        </section>
    
        <section id="verticalSliders">
          <h2>Orientation</h2>
          <div class="module">
            <p>Smart.ScrollBar can be horizontal or vertical depending on the orientation property.</p>
          </div>
          <div class="module">
            <div>
              <smart-scroll-bar></smart-scroll-bar>
              <br />
              <br />
              <smart-scroll-bar orientation="vertical"></smart-scroll-bar>
            </div>
            <br />
            <p>Vertical scrollbars</p>
          </div>
        </section>
    
        <section id="demoSliders">
          <h2>Demo</h2>
          <div class="module">
            <p>ScrollBars are controls that are used for adjusting values precisely.</p>
          </div>
          <div class="module media-controls">
            <div>
              <h2>Volumes</h2>
              <div>
                <h3>Media volume</h3>
                <div id="mediaControl" class="controls">
                  <i class="material-icons">&#xE04D;</i>
                  <smart-scroll-bar id="mediaSlider"></smart-scroll-bar>
                </div>
              </div>
              <div>
                <h3>Alarm volume</h3>
                <div id="alarmControl" class="controls">
                  <i class="material-icons">&#xE855;</i>
                  <smart-scroll-bar id="alarmSlider"></smart-scroll-bar>
                </div>
              </div>
              <div>
                <h3>Ring volume</h3>
                <div id="ringControl" class="controls">
                  <i class="material-icons">&#xE7F4;</i>
                  <smart-scroll-bar id="volumeSlider"></smart-scroll-bar>
                </div>
              </div>
            </div>
          </div>
          <div class="module power-controls">
            <div>
              <h2>Battery Saver Mode</h2>
              <div>
                <h3>
                  Low battery alert on
                  <b id="lowBatteryAlert">15</b> %
                </h3>
                <div id="mediaControl" class="controls">
                  <i class="material-icons">&#xE8B2;</i>
                  <smart-scroll-bar id="lowBatterySlider" scale-type="integer"></smart-scroll-bar>
                </div>
              </div>
              <div>
                <h3>
                  Power saver mode active on
                  <b id="powerSaver">50</b>%
                </h3>
                <div id="alarmControl" class="controls">
                  <i class="material-icons">&#xE19C;</i>
                  <smart-scroll-bar id="powerSaverSlider" scale-type="integer"></smart-scroll-bar>
                </div>
              </div>
            </div>
          </div>
        </section>
      </div>
    </template>
    
    <script>
    import { onMounted } from "vue";
    import "smart-webcomponents/source/styles/smart.default.css";
    import "smart-webcomponents/source/modules/smart.scrollbar.js";
    
    export default {
      name: "app",
      setup() {
        onMounted(() => {
          const sliders = document.querySelectorAll("smart-scroll-bar");
          sliders[1].max = 100;
          sliders[1].value = 50;
          sliders[2].max = 100;
          sliders[2].value = 100;
          sliders[3].max = 100;
          sliders[4].max = 100;
          sliders[4].value = 50;
          sliders[5].max = 100;
          sliders[5].value = 100;
          sliders[6].max = 100;
          sliders[6].value = 20;
          sliders[7].max = 100;
          sliders[7].value = 75;
          sliders[8].max = 100;
          sliders[8].value = 25;
          sliders[9].max = 100;
          sliders[9].value = 50;
          sliders[10].max = 100;
          sliders[10].value = 75;
          sliders[11].max = 100;
          sliders[11].value = 15;
          sliders[12].max = 100;
          sliders[12].value = 50;
    
          const mediaSlider = document.getElementById("mediaSlider"),
            alarmSlider = document.getElementById("alarmSlider"),
            volumeSlider = document.getElementById("volumeSlider"),
            lowBatterySlider = document.getElementById("lowBatterySlider"),
            powerSaverSlider = document.getElementById("powerSaverSlider");
    
          function setIcon(event) {
            let below = "",
              above = "",
              off = "";
            const slider = event.target;
            switch (slider) {
              case mediaSlider:
                below = '<i class="material-icons">&#xE04D;</i>';
                above = '<i class="material-icons">&#xE050;</i>';
                off = '<i class="material-icons">&#xE04F;</i>';
                break;
              case alarmSlider:
                below = above = '<i class="material-icons">&#xE855;</i>';
                off = '<i class="material-icons">&#xE857;</i>';
                break;
              case volumeSlider:
                below = '<i class="material-icons">&#xE7F5;</i>';
                above = '<i class="material-icons">&#xE7F4;</i>';
                off = '<i class="material-icons">&#xE7F6;</i>';
                break;
            }
            if (slider.value === slider.min) {
              slider.previousElementSibling.innerHTML = off;
            } else if (slider.value < slider.max / 2) {
              slider.previousElementSibling.innerHTML = below;
            } else {
              slider.previousElementSibling.innerHTML = above;
            }
          }
    
          function setBatteryLevel(event) {
            const slider = event.target;
            if (slider === lowBatterySlider) {
              document.getElementById(
                "lowBatteryAlert"
              ).textContent = slider.value.toString();
            } else {
              document.getElementById(
                "powerSaver"
              ).textContent = slider.value.toString();
            }
          }
          mediaSlider.addEventListener("change", setIcon);
          alarmSlider.addEventListener("change", setIcon);
          volumeSlider.addEventListener("change", setIcon);
          lowBatterySlider.addEventListener("change", setBatteryLevel);
          powerSaverSlider.addEventListener("change", setBatteryLevel);
        });
      }
    };
    </script>
    
    <style>
    /* fallback */
    @font-face {
      font-family: "Material Icons";
      font-style: normal;
      font-weight: 400;
      src: url(https://fonts.gstatic.com/s/materialicons/v31/2fcrYFNaTjcS6g4U3t-Y5ZjZjT5FdEJ140U2DJYC3mY.woff2)
        format("woff2");
    }
    
    .material-icons {
      font-family: "Material Icons";
      font-weight: normal;
      font-style: normal;
      font-size: inherit;
      line-height: 1;
      letter-spacing: normal;
      text-transform: none;
      display: inline-block;
      white-space: nowrap;
      word-wrap: normal;
      direction: ltr;
      -webkit-font-feature-settings: "liga";
      -webkit-font-smoothing: antialiased;
    }
    
    smart-scroll-bar {
      width: 250px;
      height: 17px;
    }
    smart-scroll-bar[orientation="vertical"] {
      width: 17px;
      height: 250px;
    }
    </style>
    		
    We can now use the smart-scroll-bar with Vue 3. Data binding and event handlers will just work right out of the box.

Running the Vue application

Start the app with
npm run dev
and open http://localhost:5173/ in your favorite web browser to see the output below:
When you are ready to ship your app to production, run the following:
npm run build
This will create a production-ready build of your app in the project's ./dist directory.

Read more about using Smart UI for Vue: https://www.htmlelements.com/docs/vue/.