Angular UI Components Documentation
The Angular ToolBar displays a bar with tools such as buttons, drop-downs and others. This guide adds the Angular ToolBar (jqxToolBar) to an app, then shows how to set its options, handle its events and call its methods.
jqwidgets-ngjqwidgets-ng/jqxtoolbar 
In an Angular project (to start one, see Getting started with Angular), add the package with the Angular CLI. It asks for a theme and adds the styles to angular.json:
ng add jqwidgets-ng
Components are standalone: add jqxToolBarModule to the imports of the component that uses it.
import { Component } from '@angular/core';
import { jqxToolBarModule } from 'jqwidgets-ng/jqxtoolbar';
@Component({
selector: 'app-root',
imports: [jqxToolBarModule],
templateUrl: './app.html'
})
export class App {}
The source of the live Default Functionality demo.
<jqxToolbar [width]="getWidth()" [height]="35"
[tools]="tools" [initTools]="initTools">
</jqxToolbar>
import { Component, ViewEncapsulation } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { jqxToolBarModule } from 'jqwidgets-ng/jqxtoolbar';
import { jqxInputModule } from 'jqwidgets-ng/jqxinput';
import { jqxButtonModule } from 'jqwidgets-ng/jqxbuttons';
import { jqxComboBoxModule } from 'jqwidgets-ng/jqxcombobox';
import { jqxDropDownListModule } from 'jqwidgets-ng/jqxdropdownlist';
// The icons come from jqxEditor's sprite, which is drawn in one dark colour. Used as a mask
// over the button's text colour, they stay visible on every theme's buttons (the filled
// Material buttons, the dark themes, a toggled button).
function appendIcon(button: HTMLElement, icon: HTMLElement): void {
button.appendChild(icon);
const style = getComputedStyle(icon);
if (style.backgroundImage === 'none') return;
icon.style.maskImage = style.backgroundImage;
icon.style.maskPosition = style.backgroundPosition;
icon.style.maskRepeat = 'no-repeat';
// its own colour, so the site's dark mode does not take the light fill for a light background
icon.style.color = 'inherit';
icon.style.setProperty('background', 'currentColor', 'important');
}
@Component({
imports: [
CommonModule,
FormsModule,
jqxToolBarModule,
jqxInputModule,
jqxButtonModule,
jqxComboBoxModule,
jqxDropDownListModule
],
selector: 'app-root',
templateUrl: './app.html',
styleUrl: './app.css',
encapsulation: ViewEncapsulation.None
})
export class App {
getWidth(): any {
if (document.body.offsetWidth < 700) {
return '90%';
}
return 700;
}
tools: string =
'toggleButton toggleButton toggleButton | toggleButton | dropdownlist combobox | input | custom';
initTools: any = (
type: string,
index: number,
tool: any,
menuToolIninitialization: any
): void => {
let theme: string = jqx.theme || '';
let icon = document.createElement('div');
if (type == 'toggleButton') {
icon.className =
'jqx-editor-toolbar-icon jqx-editor-toolbar-icon-' + theme + ' buttonIcon ';
}
switch (index) {
case 0:
icon.className +=
'jqx-editor-toolbar-icon-bold jqx-editor-toolbar-icon-bold-' + theme;
icon.setAttribute('title', 'Bold');
appendIcon(tool[0], icon);
break;
case 1:
icon.className +=
'jqx-editor-toolbar-icon-italic jqx-editor-toolbar-icon-italic-' + theme;
icon.setAttribute('title', 'Italic');
appendIcon(tool[0], icon);
break;
case 2:
icon.className +=
'jqx-editor-toolbar-icon-underline jqx-editor-toolbar-icon-underline-' + theme;
icon.setAttribute('title', 'Underline');
appendIcon(tool[0], icon);
break;
case 3:
tool.jqxToggleButton({ width: 80, toggled: true });
tool.text('Enabled');
tool.on('click', () => {
let toggled = tool.jqxToggleButton('toggled');
if (toggled) {
tool.text('Enabled');
} else {
tool.text('Disabled');
}
});
break;
case 4:
tool.jqxDropDownList({
width: 130,
source: [
"<span style='font-family: Courier New;'>Courier New</span>",
"<span style='font-family: Times New Roman;'>Times New Roman</span>",
"<span style='font-family: Verdana;'>Verdana</span>"
],
selectedIndex: 1
});
break;
case 5:
tool.jqxComboBox({
width: 50,
source: [8, 9, 10, 11, 12, 14, 16, 18, 20],
selectedIndex: 3
});
break;
case 6:
tool.jqxInput({ width: 200, placeHolder: 'Type here to search...' });
break;
case 7:
let button = document.createElement('div');
let img = document.createElement('img');
img.src = 'https://www.jqwidgets.com/angular/images/administrator.png';
img.title = 'Custom tool';
button.appendChild(img);
tool[0].appendChild(button);
tool.jqxButton({ height: 15 });
break;
}
};
}html, body {
width: 100vw;
height: 100vh;
padding: 0;
margin: 0;
}
.buttonIcon {
margin: -5px 0 0 -3px;
width: 16px;
height: 17px;
}
Options are inputs, bound with [name]="value".
Events are outputs named on plus the event name with a capital first letter. For example, open: This event is triggered when the minimize pop-up menu is opened.
<jqxToolBar (onOpen)="onOpen($event)"></jqxToolBar>
onOpen(event: any): void {
console.log(event.args);
}
Get the component with a signal query and call its methods. For example, refresh: Refreshes the widget.
<jqxToolBar #myToolBar></jqxToolBar>
import { Component, viewChild } from '@angular/core';
import { jqxToolBarModule, jqxToolBarComponent } from 'jqwidgets-ng/jqxtoolbar';
@Component({
selector: 'app-root',
imports: [jqxToolBarModule],
templateUrl: './app.html'
})
export class App {
readonly myToolBar = viewChild.required<jqxToolBarComponent>('myToolBar');
run(): void {
this.myToolBar().refresh();
}
}