Angular UI Components Documentation

Angular ScrollBar Component

The ScrollBar component for Angular represents a widget that provides a scroll bar that has a sliding thumb whose position corresponds to a value.

1. Installation

The easiest way to get started with jQWidgets UI for Angular is to use the Angular CLI Tool. To scaffold your project structure, follow its installation instructions.

npm install -g @angular/cli
ng new jqwidgets-project
cd jqwidgets-project

Install jQWidgets

jQWidgets Angular UI comes packaged with Angular CLI schematics to make creating Angular applications easier. Schematics are included with both @angular/cdk and jqwidgets-ng. Once you install the npm packages, they will be available through the Angular CLI.

Angular CLI supports the addition of packages through the ng add command. The ng add command provides faster and more user-friendly package installation. To install the jQWidgets UI for Angular package, use ng add and add the name of the NPM package:

ng add jqwidgets-ng

Alternatively, you can use the standard installation (Manual Setup)

jQWidgets UI for Angular is distributed as jqwidgets-ng NPM package

  1. Download and install the package.
    npm install jqwidgets-ng
  2. Adding CSS reference

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

    @import 'jqwidgets-ng/jqwidgets/styles/jqx.base.css';

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

    "styles": [
    	"node_modules/jqwidgets-ng/jqwidgets/styles/jqx.base.css"
    ]
    

2. Add the HTML for jQWidgets component in src/app/app.component.html

app.component.html


<div style="margin-bottom: 10px;" #VerticalDiv>Vertical</div>
<jqxScrollBar [theme]="'fluent'" (onValueChanged)="onValueChangedVertical($event)"
              [width]="18" [height]="280"
              [min]="0" [max]="1000" [vertical]="true">
</jqxScrollBar>
<div style="margin: 10px 0;" #HorizontalDiv>Horizontal</div>
<jqxScrollBar [theme]="'fluent'" (onValueChanged)="onValueChangedHorizontal($event)"
              [width]="280" [height]="18"
              [min]="0" [max]="1000">
</jqxScrollBar>	

3. Setup Component Logic

app.component.ts


import { Component, ViewChild, ElementRef } from '@angular/core';

import { jqxScrollbarModule, jqxScrollbarComponent } from 'jqwidgets-ng/jqxscrollbar';
@Component({
    selector: 'app-root',
    imports: [jqxScrollbarModule],
    standalone: true,
    templateUrl: './app.component.html'
})

export class AppComponent {
    @ViewChild('HorizontalDiv') HorizontalDiv: ElementRef;
    @ViewChild('VerticalDiv') VerticalDiv: ElementRef;

    onValueChangedVertical(event: any): void {
        this.VerticalDiv.nativeElement.innerHTML = 'Vertical (' + parseInt(event.currentValue) + ')';
    };

    onValueChangedHorizontal(event: any): void {
        this.HorizontalDiv.nativeElement.innerHTML = 'Horizontal (' + parseInt(event.currentValue) + ')';
    };
}

Summary

jQWidgets UI for Angular provides an easy way to integrate robust UI components into your Angular project. By using either the ng add command or manual setup, you can quickly get started. Once the setup is complete, you can add the desired jQWidgets components and configure them in your Angular components to match your application requirements.

ScrollBar API

API Reference of the jQWidgets ScrollBar component for Angular: ScrollBar API