Having trouble getting help?
Contact Support
Contact Support
Set command customization in Angular Toolbar component
27 Apr 20242 minutes to read
The htmlAttributes
property of the Toolbar item is used to set the HTML attributes (‘ID’, ‘class’, ‘style’ ,’role’) for the commands.
When style attributes are added, if the same attributes were already present, they will be replaced. This is not so in the case of class
attribute. Classes will be added to the element instead of replacing the existing ones.
Single or multiple CSS classes can be added to the Toolbar commands using the Toolbar item cssClass
property.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { ToolbarModule } from '@syncfusion/ej2-angular-navigations'
import { TooltipModule } from '@syncfusion/ej2-angular-popups'
import { Component, ViewChild } from '@angular/core';
import { ToolbarComponent } from '@syncfusion/ej2-angular-navigations';
@Component({
imports: [
ToolbarModule, TooltipModule
],
standalone: true,
selector: 'app-container',
template: `
<ejs-toolbar>
<e-items>
<e-item text='Bold' [htmlAttributes] = 'boldAttribute'></e-item>
<e-item text='Italic' [htmlAttributes] = 'italicAttribute'></e-item>
<e-item text='Underline' [htmlAttributes] = 'underAttribute'></e-item>
<e-item type='Separator'></e-item>
<e-item text='Uppercase' cssClass = 'e-txt-casing'></e-item>
</e-items>
</ejs-toolbar>
`
})
export class AppComponent {
@ViewChild('element') element?: any;
public boldAttribute: any = { 'class': 'custom_bold', 'id': 'itemId' };
public italicAttribute: any = { 'class': 'custom_italic' };
public underAttribute: any = { 'class': 'custom_underline' };
ngAfterViewInit() {
}
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));