Quill Access and dynamic add toolbar from quill instance

for dynamic custom toolbar, we need access toolbar from quill instance in javascript, this topic show how to access toolbar via quill instance and dynamic add button to toolbar

 

{ Access Toolbar from Quill Instance }

quill.container.previousSibling.

 

{ Dynamic Add a button to Toolbar  }

      //create btn
      let button = document.createElement("button");
      //display button text
      button.innerHTML = ">_";
      button.onclick = function() {
        //action code here
      };

      //create btn container
      let buttonContainer = document.createElement("span");
      buttonContainer.setAttribute("class", "ql-formats");
      buttonContainer.appendChild(button);
      
      //add to toolbar
      quill.container.previousSibling.appendChild(buttonContainer);