Set command customization in EJ2 TypeScript Toolbar control

2 May 20232 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 {Toolbar} from '@syncfusion/ej2-navigations';
let toolbar: Toolbar = new Toolbar({
    width: 300,
    items: [
        { text: "Bold", type: 'Button', htmlAttributes: { 'class': 'custom_bold', 'id': 'itemId' } },
        { text: "Italic", htmlAttributes: { 'class': 'custom_italic' }  },
        { text: "Underline", htmlAttributes: { 'class': 'custom_underline' } },
        { type: "Separator" },
        { text: "Uppercase", cssClass: "e-txt-casing" }
<!DOCTYPE html>
<html lang="en">

    <title>Essential JS 2 Toolbar</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="Typescript Toolbar Controls" />
    <meta name="author" content="Syncfusion" />
    <link href="index.css" rel="stylesheet" />
    <link href="" rel="stylesheet" />
    <link href="" rel="stylesheet" />
    <script src=""></script>
    <script src="systemjs.config.js"></script>
<script src="" type ="text/javascript"></script>

    <div id='loader'>LOADING....</div>
    <div id='container'>
        <div id='element'></div>
        <div id='result'></div>