Angular UI Components Documentation
Angular NavBar Component
The NavBar component for Angular represents a small widget which is built from UL and LI tags. It can be used for creating responsive horizontal/vertical layouts or simple navigation menus.
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
- Download and install the package.
npm install jqwidgets-ng
- 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="width: 80%;">
NavBar with 2 Items. Each item is with 50% width.
<br />
<jqxNavBar [theme]="'fluent'" id="navBar1" [height]="40" [selectedItem]="0">
<ul>
<li>1</li>
<li>2</li>
</ul>
</jqxNavBar>
<br />
NavBar with 3 Items. Each item is with 33.33% width.
<br />
<jqxNavBar [theme]="'fluent'" id="navBar2" [height]="40" [selectedItem]="0">
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
</jqxNavBar>
<br />
NavBar with 4 Items. Each item is with 25% width.
<br />
<jqxNavBar [theme]="'fluent'" id="navBar3" [height]="40" [selectedItem]="0">
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
</jqxNavBar>
<br />
NavBar with 5 Items. Each item is with 20% width.
<br />
<jqxNavBar [theme]="'fluent'" id="navBar4" [height]="40" [selectedItem]="0">
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>
</jqxNavBar>
<br />
NavBar with more than 5 Items. Items are displayed in 2 columns and each item is with 50% width.
<br />
<jqxNavBar [theme]="'fluent'" id="navBar5" [height]="160" [selectedItem]="0">
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
<li>7</li>
<li>8</li>
</ul>
</jqxNavBar>
<br />
NavBar with "columns" set to ["30%", "50%", "20%"].
<br />
<jqxNavBar [theme]="'fluent'" id="navBar6" [height]="40" [selectedItem]="0" [columns]="['30%', '50%', '20%']">
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
</jqxNavBar>
</div>
3. Setup Component Logic
app.component.ts
import { Component } from '@angular/core';
import { jqxNavBarModule, jqxNavBarComponent } from 'jqwidgets-ng/jqxnavbar';
@Component({
selector: 'app-root',
imports: [jqxNavBarModule],
standalone: true,
templateUrl: './app.component.html'
})
export class AppComponent {
}