We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Select Toolbar Item

How do I set the a toolbar item as active (and selected) by default programmatically?



1 Reply

RM Ruksar Moosa Sait Syncfusion Team November 2, 2022 09:38 AM UTC

Hi Addy,


You can select or make the toolbar item active by setting focus to the respective toolbar item like the below code.


let toolbarItem = document.querySelectorAll('.e-toolbar-item');
let focusbuttonButton = new Button();

focusbutton.appendTo('#focusbutton');

    focusbutton.element.onclick = (): void => {

        (toolbarItem[0].firstChild as HTMLElement).focus();

    }



Sample: https://stackblitz.com/edit/beytfz-2ngite?file=index.ts,index.html


Output:

Graphical user interface, application

Description automatically generated


Regards,

Ruksar Moosa Sait


Loader.
Live Chat Icon For mobile
Up arrow icon